mesheditor 0.0.0-stage → 1.0.2

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 (497) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +853 -2
  3. package/dist-lib/esm/AIAgentService.d.ts +107 -0
  4. package/dist-lib/esm/AIAgentService.d.ts.map +1 -0
  5. package/dist-lib/esm/AIAgentService.js +1471 -0
  6. package/dist-lib/esm/AIAgentService.js.map +1 -0
  7. package/dist-lib/esm/MeshEditorApp.d.ts +413 -0
  8. package/dist-lib/esm/MeshEditorApp.d.ts.map +1 -0
  9. package/dist-lib/esm/MeshEditorApp.js +9093 -0
  10. package/dist-lib/esm/MeshEditorApp.js.map +1 -0
  11. package/dist-lib/esm/MeshEditorService.d.ts +460 -0
  12. package/dist-lib/esm/MeshEditorService.d.ts.map +1 -0
  13. package/dist-lib/esm/MeshEditorService.js +7084 -0
  14. package/dist-lib/esm/MeshEditorService.js.map +1 -0
  15. package/dist-lib/esm/Neural3DGeneratorService.d.ts +89 -0
  16. package/dist-lib/esm/Neural3DGeneratorService.d.ts.map +1 -0
  17. package/dist-lib/esm/Neural3DGeneratorService.js +1398 -0
  18. package/dist-lib/esm/Neural3DGeneratorService.js.map +1 -0
  19. package/dist-lib/esm/adapters/BrowserPlatformAdapter.d.ts +17 -0
  20. package/dist-lib/esm/adapters/BrowserPlatformAdapter.d.ts.map +1 -0
  21. package/dist-lib/esm/adapters/BrowserPlatformAdapter.js +26 -0
  22. package/dist-lib/esm/adapters/BrowserPlatformAdapter.js.map +1 -0
  23. package/dist-lib/esm/adapters/ElectronPlatformAdapter.d.ts +33 -0
  24. package/dist-lib/esm/adapters/ElectronPlatformAdapter.d.ts.map +1 -0
  25. package/dist-lib/esm/adapters/ElectronPlatformAdapter.js +337 -0
  26. package/dist-lib/esm/adapters/ElectronPlatformAdapter.js.map +1 -0
  27. package/dist-lib/esm/adapters/HostAppAdapter.d.ts +55 -0
  28. package/dist-lib/esm/adapters/HostAppAdapter.d.ts.map +1 -0
  29. package/dist-lib/esm/adapters/HostAppAdapter.js +76 -0
  30. package/dist-lib/esm/adapters/HostAppAdapter.js.map +1 -0
  31. package/dist-lib/esm/adapters/PlatformAdapter.d.ts +99 -0
  32. package/dist-lib/esm/adapters/PlatformAdapter.d.ts.map +1 -0
  33. package/dist-lib/esm/adapters/PlatformAdapter.js +2 -0
  34. package/dist-lib/esm/adapters/PlatformAdapter.js.map +1 -0
  35. package/dist-lib/esm/adapters/index.d.ts +14 -0
  36. package/dist-lib/esm/adapters/index.d.ts.map +1 -0
  37. package/dist-lib/esm/adapters/index.js +16 -0
  38. package/dist-lib/esm/adapters/index.js.map +1 -0
  39. package/dist-lib/esm/assets/fonts/Droid_Sans_Bold.json +1 -0
  40. package/dist-lib/esm/assets/fonts/Droid_Sans_Regular.json +1 -0
  41. package/dist-lib/esm/assets/fonts/Kenney_Future_Regular.json +1 -0
  42. package/dist-lib/esm/baking/TextureBaker.d.ts +85 -0
  43. package/dist-lib/esm/baking/TextureBaker.d.ts.map +1 -0
  44. package/dist-lib/esm/baking/TextureBaker.js +710 -0
  45. package/dist-lib/esm/baking/TextureBaker.js.map +1 -0
  46. package/dist-lib/esm/builtInSkills.d.ts +20 -0
  47. package/dist-lib/esm/builtInSkills.d.ts.map +1 -0
  48. package/dist-lib/esm/builtInSkills.js +187 -0
  49. package/dist-lib/esm/builtInSkills.js.map +1 -0
  50. package/dist-lib/esm/compression/ModelCompressor.d.ts +88 -0
  51. package/dist-lib/esm/compression/ModelCompressor.d.ts.map +1 -0
  52. package/dist-lib/esm/compression/ModelCompressor.js +554 -0
  53. package/dist-lib/esm/compression/ModelCompressor.js.map +1 -0
  54. package/dist-lib/esm/decals/DecalController.d.ts +148 -0
  55. package/dist-lib/esm/decals/DecalController.d.ts.map +1 -0
  56. package/dist-lib/esm/decals/DecalController.js +1032 -0
  57. package/dist-lib/esm/decals/DecalController.js.map +1 -0
  58. package/dist-lib/esm/decals/decalAssetUrls.d.ts +2 -0
  59. package/dist-lib/esm/decals/decalAssetUrls.d.ts.map +1 -0
  60. package/dist-lib/esm/decals/decalAssetUrls.js +17 -0
  61. package/dist-lib/esm/decals/decalAssetUrls.js.map +1 -0
  62. package/dist-lib/esm/geometry/architecture.d.ts +115 -0
  63. package/dist-lib/esm/geometry/architecture.d.ts.map +1 -0
  64. package/dist-lib/esm/geometry/architecture.js +832 -0
  65. package/dist-lib/esm/geometry/architecture.js.map +1 -0
  66. package/dist-lib/esm/geometry/bevelModifier.d.ts +60 -0
  67. package/dist-lib/esm/geometry/bevelModifier.d.ts.map +1 -0
  68. package/dist-lib/esm/geometry/bevelModifier.js +346 -0
  69. package/dist-lib/esm/geometry/bevelModifier.js.map +1 -0
  70. package/dist-lib/esm/geometry/facetSurfaceUtils.d.ts +128 -0
  71. package/dist-lib/esm/geometry/facetSurfaceUtils.d.ts.map +1 -0
  72. package/dist-lib/esm/geometry/facetSurfaceUtils.js +677 -0
  73. package/dist-lib/esm/geometry/facetSurfaceUtils.js.map +1 -0
  74. package/dist-lib/esm/geometry/roundedBox.d.ts +16 -0
  75. package/dist-lib/esm/geometry/roundedBox.d.ts.map +1 -0
  76. package/dist-lib/esm/geometry/roundedBox.js +134 -0
  77. package/dist-lib/esm/geometry/roundedBox.js.map +1 -0
  78. package/dist-lib/esm/index.d.ts +22 -0
  79. package/dist-lib/esm/index.d.ts.map +1 -0
  80. package/dist-lib/esm/index.js +51 -0
  81. package/dist-lib/esm/index.js.map +1 -0
  82. package/dist-lib/esm/pathExtrusion/PathExtrusionController.d.ts +60 -0
  83. package/dist-lib/esm/pathExtrusion/PathExtrusionController.d.ts.map +1 -0
  84. package/dist-lib/esm/pathExtrusion/PathExtrusionController.js +484 -0
  85. package/dist-lib/esm/pathExtrusion/PathExtrusionController.js.map +1 -0
  86. package/dist-lib/esm/pathExtrusion/PathExtrusionStudio.d.ts +77 -0
  87. package/dist-lib/esm/pathExtrusion/PathExtrusionStudio.d.ts.map +1 -0
  88. package/dist-lib/esm/pathExtrusion/PathExtrusionStudio.js +1793 -0
  89. package/dist-lib/esm/pathExtrusion/PathExtrusionStudio.js.map +1 -0
  90. package/dist-lib/esm/pathExtrusion/PathFactory.d.ts +96 -0
  91. package/dist-lib/esm/pathExtrusion/PathFactory.d.ts.map +1 -0
  92. package/dist-lib/esm/pathExtrusion/PathFactory.js +628 -0
  93. package/dist-lib/esm/pathExtrusion/PathFactory.js.map +1 -0
  94. package/dist-lib/esm/pathExtrusion/index.d.ts +5 -0
  95. package/dist-lib/esm/pathExtrusion/index.d.ts.map +1 -0
  96. package/dist-lib/esm/pathExtrusion/index.js +5 -0
  97. package/dist-lib/esm/pathExtrusion/index.js.map +1 -0
  98. package/dist-lib/esm/pathExtrusion/types.d.ts +51 -0
  99. package/dist-lib/esm/pathExtrusion/types.d.ts.map +1 -0
  100. package/dist-lib/esm/pathExtrusion/types.js +2 -0
  101. package/dist-lib/esm/pathExtrusion/types.js.map +1 -0
  102. package/dist-lib/esm/plugin.d.ts +251 -0
  103. package/dist-lib/esm/plugin.d.ts.map +1 -0
  104. package/dist-lib/esm/plugin.js +145 -0
  105. package/dist-lib/esm/plugin.js.map +1 -0
  106. package/dist-lib/esm/rigging/WeightPaintController.d.ts +163 -0
  107. package/dist-lib/esm/rigging/WeightPaintController.d.ts.map +1 -0
  108. package/dist-lib/esm/rigging/WeightPaintController.js +1422 -0
  109. package/dist-lib/esm/rigging/WeightPaintController.js.map +1 -0
  110. package/dist-lib/esm/sculpting/SculptController.d.ts +147 -0
  111. package/dist-lib/esm/sculpting/SculptController.d.ts.map +1 -0
  112. package/dist-lib/esm/sculpting/SculptController.js +2039 -0
  113. package/dist-lib/esm/sculpting/SculptController.js.map +1 -0
  114. package/dist-lib/esm/sdf/index.d.ts +3 -0
  115. package/dist-lib/esm/sdf/index.d.ts.map +1 -0
  116. package/dist-lib/esm/sdf/index.js +3 -0
  117. package/dist-lib/esm/sdf/index.js.map +1 -0
  118. package/dist-lib/esm/sdf/sdfPrimitives.d.ts +98 -0
  119. package/dist-lib/esm/sdf/sdfPrimitives.d.ts.map +1 -0
  120. package/dist-lib/esm/sdf/sdfPrimitives.js +403 -0
  121. package/dist-lib/esm/sdf/sdfPrimitives.js.map +1 -0
  122. package/dist-lib/esm/sdf/surfaceNets.d.ts +30 -0
  123. package/dist-lib/esm/sdf/surfaceNets.d.ts.map +1 -0
  124. package/dist-lib/esm/sdf/surfaceNets.js +400 -0
  125. package/dist-lib/esm/sdf/surfaceNets.js.map +1 -0
  126. package/dist-lib/esm/styles.d.ts +12 -0
  127. package/dist-lib/esm/styles.d.ts.map +1 -0
  128. package/dist-lib/esm/styles.js +33 -0
  129. package/dist-lib/esm/styles.js.map +1 -0
  130. package/dist-lib/esm/template.d.ts +13 -0
  131. package/dist-lib/esm/template.d.ts.map +1 -0
  132. package/dist-lib/esm/template.js +20 -0
  133. package/dist-lib/esm/template.js.map +1 -0
  134. package/dist-lib/esm/textMesh/TextMeshController.d.ts +62 -0
  135. package/dist-lib/esm/textMesh/TextMeshController.d.ts.map +1 -0
  136. package/dist-lib/esm/textMesh/TextMeshController.js +405 -0
  137. package/dist-lib/esm/textMesh/TextMeshController.js.map +1 -0
  138. package/dist-lib/esm/textures/AITextureGenerator.d.ts +120 -0
  139. package/dist-lib/esm/textures/AITextureGenerator.d.ts.map +1 -0
  140. package/dist-lib/esm/textures/AITextureGenerator.js +946 -0
  141. package/dist-lib/esm/textures/AITextureGenerator.js.map +1 -0
  142. package/dist-lib/esm/textures/ExternalImageGeneratorService.d.ts +63 -0
  143. package/dist-lib/esm/textures/ExternalImageGeneratorService.d.ts.map +1 -0
  144. package/dist-lib/esm/textures/ExternalImageGeneratorService.js +880 -0
  145. package/dist-lib/esm/textures/ExternalImageGeneratorService.js.map +1 -0
  146. package/dist-lib/esm/tools/AbstractTool.d.ts +69 -0
  147. package/dist-lib/esm/tools/AbstractTool.d.ts.map +1 -0
  148. package/dist-lib/esm/tools/AbstractTool.js +129 -0
  149. package/dist-lib/esm/tools/AbstractTool.js.map +1 -0
  150. package/dist-lib/esm/tools/ToolExecutionContext.d.ts +41 -0
  151. package/dist-lib/esm/tools/ToolExecutionContext.d.ts.map +1 -0
  152. package/dist-lib/esm/tools/ToolExecutionContext.js +2 -0
  153. package/dist-lib/esm/tools/ToolExecutionContext.js.map +1 -0
  154. package/dist-lib/esm/tools/ToolInterface.d.ts +105 -0
  155. package/dist-lib/esm/tools/ToolInterface.d.ts.map +1 -0
  156. package/dist-lib/esm/tools/ToolInterface.js +2 -0
  157. package/dist-lib/esm/tools/ToolInterface.js.map +1 -0
  158. package/dist-lib/esm/tools/ToolRegistry.d.ts +44 -0
  159. package/dist-lib/esm/tools/ToolRegistry.d.ts.map +1 -0
  160. package/dist-lib/esm/tools/ToolRegistry.js +116 -0
  161. package/dist-lib/esm/tools/ToolRegistry.js.map +1 -0
  162. package/dist-lib/esm/tools/builtin/ApplyMaterialTool.d.ts +35 -0
  163. package/dist-lib/esm/tools/builtin/ApplyMaterialTool.d.ts.map +1 -0
  164. package/dist-lib/esm/tools/builtin/ApplyMaterialTool.js +49 -0
  165. package/dist-lib/esm/tools/builtin/ApplyMaterialTool.js.map +1 -0
  166. package/dist-lib/esm/tools/builtin/AutoUVMappingTool.d.ts +35 -0
  167. package/dist-lib/esm/tools/builtin/AutoUVMappingTool.d.ts.map +1 -0
  168. package/dist-lib/esm/tools/builtin/AutoUVMappingTool.js +55 -0
  169. package/dist-lib/esm/tools/builtin/AutoUVMappingTool.js.map +1 -0
  170. package/dist-lib/esm/tools/builtin/BakeTexturesTool.d.ts +43 -0
  171. package/dist-lib/esm/tools/builtin/BakeTexturesTool.d.ts.map +1 -0
  172. package/dist-lib/esm/tools/builtin/BakeTexturesTool.js +82 -0
  173. package/dist-lib/esm/tools/builtin/BakeTexturesTool.js.map +1 -0
  174. package/dist-lib/esm/tools/builtin/BooleanOperationTool.d.ts +52 -0
  175. package/dist-lib/esm/tools/builtin/BooleanOperationTool.d.ts.map +1 -0
  176. package/dist-lib/esm/tools/builtin/BooleanOperationTool.js +87 -0
  177. package/dist-lib/esm/tools/builtin/BooleanOperationTool.js.map +1 -0
  178. package/dist-lib/esm/tools/builtin/BuildVoxelMeshTool.d.ts +79 -0
  179. package/dist-lib/esm/tools/builtin/BuildVoxelMeshTool.d.ts.map +1 -0
  180. package/dist-lib/esm/tools/builtin/BuildVoxelMeshTool.js +171 -0
  181. package/dist-lib/esm/tools/builtin/BuildVoxelMeshTool.js.map +1 -0
  182. package/dist-lib/esm/tools/builtin/CloneArrayTool.d.ts +76 -0
  183. package/dist-lib/esm/tools/builtin/CloneArrayTool.d.ts.map +1 -0
  184. package/dist-lib/esm/tools/builtin/CloneArrayTool.js +116 -0
  185. package/dist-lib/esm/tools/builtin/CloneArrayTool.js.map +1 -0
  186. package/dist-lib/esm/tools/builtin/CreateArchTool.d.ts +119 -0
  187. package/dist-lib/esm/tools/builtin/CreateArchTool.d.ts.map +1 -0
  188. package/dist-lib/esm/tools/builtin/CreateArchTool.js +90 -0
  189. package/dist-lib/esm/tools/builtin/CreateArchTool.js.map +1 -0
  190. package/dist-lib/esm/tools/builtin/CreateColumnTool.d.ts +115 -0
  191. package/dist-lib/esm/tools/builtin/CreateColumnTool.d.ts.map +1 -0
  192. package/dist-lib/esm/tools/builtin/CreateColumnTool.js +106 -0
  193. package/dist-lib/esm/tools/builtin/CreateColumnTool.js.map +1 -0
  194. package/dist-lib/esm/tools/builtin/CreateLatheTool.d.ts +88 -0
  195. package/dist-lib/esm/tools/builtin/CreateLatheTool.d.ts.map +1 -0
  196. package/dist-lib/esm/tools/builtin/CreateLatheTool.js +61 -0
  197. package/dist-lib/esm/tools/builtin/CreateLatheTool.js.map +1 -0
  198. package/dist-lib/esm/tools/builtin/CreateMaterialTool.d.ts +115 -0
  199. package/dist-lib/esm/tools/builtin/CreateMaterialTool.d.ts.map +1 -0
  200. package/dist-lib/esm/tools/builtin/CreateMaterialTool.js +213 -0
  201. package/dist-lib/esm/tools/builtin/CreateMaterialTool.js.map +1 -0
  202. package/dist-lib/esm/tools/builtin/CreateMoldingTool.d.ts +121 -0
  203. package/dist-lib/esm/tools/builtin/CreateMoldingTool.d.ts.map +1 -0
  204. package/dist-lib/esm/tools/builtin/CreateMoldingTool.js +96 -0
  205. package/dist-lib/esm/tools/builtin/CreateMoldingTool.js.map +1 -0
  206. package/dist-lib/esm/tools/builtin/CreatePrimitiveTool.d.ts +163 -0
  207. package/dist-lib/esm/tools/builtin/CreatePrimitiveTool.d.ts.map +1 -0
  208. package/dist-lib/esm/tools/builtin/CreatePrimitiveTool.js +303 -0
  209. package/dist-lib/esm/tools/builtin/CreatePrimitiveTool.js.map +1 -0
  210. package/dist-lib/esm/tools/builtin/CreateRoofTool.d.ts +121 -0
  211. package/dist-lib/esm/tools/builtin/CreateRoofTool.d.ts.map +1 -0
  212. package/dist-lib/esm/tools/builtin/CreateRoofTool.js +109 -0
  213. package/dist-lib/esm/tools/builtin/CreateRoofTool.js.map +1 -0
  214. package/dist-lib/esm/tools/builtin/CreateRoundedBoxTool.d.ts +102 -0
  215. package/dist-lib/esm/tools/builtin/CreateRoundedBoxTool.d.ts.map +1 -0
  216. package/dist-lib/esm/tools/builtin/CreateRoundedBoxTool.js +80 -0
  217. package/dist-lib/esm/tools/builtin/CreateRoundedBoxTool.js.map +1 -0
  218. package/dist-lib/esm/tools/builtin/CreateSdfMeshTool.d.ts +225 -0
  219. package/dist-lib/esm/tools/builtin/CreateSdfMeshTool.d.ts.map +1 -0
  220. package/dist-lib/esm/tools/builtin/CreateSdfMeshTool.js +239 -0
  221. package/dist-lib/esm/tools/builtin/CreateSdfMeshTool.js.map +1 -0
  222. package/dist-lib/esm/tools/builtin/CreateStairsTool.d.ts +136 -0
  223. package/dist-lib/esm/tools/builtin/CreateStairsTool.d.ts.map +1 -0
  224. package/dist-lib/esm/tools/builtin/CreateStairsTool.js +120 -0
  225. package/dist-lib/esm/tools/builtin/CreateStairsTool.js.map +1 -0
  226. package/dist-lib/esm/tools/builtin/CreateTextMeshTool.d.ts +95 -0
  227. package/dist-lib/esm/tools/builtin/CreateTextMeshTool.d.ts.map +1 -0
  228. package/dist-lib/esm/tools/builtin/CreateTextMeshTool.js +132 -0
  229. package/dist-lib/esm/tools/builtin/CreateTextMeshTool.js.map +1 -0
  230. package/dist-lib/esm/tools/builtin/CreateTubeTool.d.ts +88 -0
  231. package/dist-lib/esm/tools/builtin/CreateTubeTool.d.ts.map +1 -0
  232. package/dist-lib/esm/tools/builtin/CreateTubeTool.js +60 -0
  233. package/dist-lib/esm/tools/builtin/CreateTubeTool.js.map +1 -0
  234. package/dist-lib/esm/tools/builtin/CreateWallTool.d.ts +146 -0
  235. package/dist-lib/esm/tools/builtin/CreateWallTool.d.ts.map +1 -0
  236. package/dist-lib/esm/tools/builtin/CreateWallTool.js +125 -0
  237. package/dist-lib/esm/tools/builtin/CreateWallTool.js.map +1 -0
  238. package/dist-lib/esm/tools/builtin/DecalTool.d.ts +77 -0
  239. package/dist-lib/esm/tools/builtin/DecalTool.d.ts.map +1 -0
  240. package/dist-lib/esm/tools/builtin/DecalTool.js +144 -0
  241. package/dist-lib/esm/tools/builtin/DecalTool.js.map +1 -0
  242. package/dist-lib/esm/tools/builtin/DeleteMeshTool.d.ts +21 -0
  243. package/dist-lib/esm/tools/builtin/DeleteMeshTool.d.ts.map +1 -0
  244. package/dist-lib/esm/tools/builtin/DeleteMeshTool.js +43 -0
  245. package/dist-lib/esm/tools/builtin/DeleteMeshTool.js.map +1 -0
  246. package/dist-lib/esm/tools/builtin/ExecuteBabylonCodeTool.d.ts +22 -0
  247. package/dist-lib/esm/tools/builtin/ExecuteBabylonCodeTool.d.ts.map +1 -0
  248. package/dist-lib/esm/tools/builtin/ExecuteBabylonCodeTool.js +96 -0
  249. package/dist-lib/esm/tools/builtin/ExecuteBabylonCodeTool.js.map +1 -0
  250. package/dist-lib/esm/tools/builtin/ExtrudePolygonTool.d.ts +115 -0
  251. package/dist-lib/esm/tools/builtin/ExtrudePolygonTool.d.ts.map +1 -0
  252. package/dist-lib/esm/tools/builtin/ExtrudePolygonTool.js +77 -0
  253. package/dist-lib/esm/tools/builtin/ExtrudePolygonTool.js.map +1 -0
  254. package/dist-lib/esm/tools/builtin/ExtrudeShapeTool.d.ts +105 -0
  255. package/dist-lib/esm/tools/builtin/ExtrudeShapeTool.d.ts.map +1 -0
  256. package/dist-lib/esm/tools/builtin/ExtrudeShapeTool.js +69 -0
  257. package/dist-lib/esm/tools/builtin/ExtrudeShapeTool.js.map +1 -0
  258. package/dist-lib/esm/tools/builtin/FacetArcTool.d.ts +37 -0
  259. package/dist-lib/esm/tools/builtin/FacetArcTool.d.ts.map +1 -0
  260. package/dist-lib/esm/tools/builtin/FacetArcTool.js +58 -0
  261. package/dist-lib/esm/tools/builtin/FacetArcTool.js.map +1 -0
  262. package/dist-lib/esm/tools/builtin/FacetCutThroughTool.d.ts +31 -0
  263. package/dist-lib/esm/tools/builtin/FacetCutThroughTool.d.ts.map +1 -0
  264. package/dist-lib/esm/tools/builtin/FacetCutThroughTool.js +50 -0
  265. package/dist-lib/esm/tools/builtin/FacetCutThroughTool.js.map +1 -0
  266. package/dist-lib/esm/tools/builtin/FacetExtrudeTool.d.ts +31 -0
  267. package/dist-lib/esm/tools/builtin/FacetExtrudeTool.d.ts.map +1 -0
  268. package/dist-lib/esm/tools/builtin/FacetExtrudeTool.js +50 -0
  269. package/dist-lib/esm/tools/builtin/FacetExtrudeTool.js.map +1 -0
  270. package/dist-lib/esm/tools/builtin/FacetInsetTool.d.ts +35 -0
  271. package/dist-lib/esm/tools/builtin/FacetInsetTool.d.ts.map +1 -0
  272. package/dist-lib/esm/tools/builtin/FacetInsetTool.js +56 -0
  273. package/dist-lib/esm/tools/builtin/FacetInsetTool.js.map +1 -0
  274. package/dist-lib/esm/tools/builtin/GenerateNeuralMeshTool.d.ts +132 -0
  275. package/dist-lib/esm/tools/builtin/GenerateNeuralMeshTool.d.ts.map +1 -0
  276. package/dist-lib/esm/tools/builtin/GenerateNeuralMeshTool.js +456 -0
  277. package/dist-lib/esm/tools/builtin/GenerateNeuralMeshTool.js.map +1 -0
  278. package/dist-lib/esm/tools/builtin/GenerateTextureTool.d.ts +88 -0
  279. package/dist-lib/esm/tools/builtin/GenerateTextureTool.d.ts.map +1 -0
  280. package/dist-lib/esm/tools/builtin/GenerateTextureTool.js +217 -0
  281. package/dist-lib/esm/tools/builtin/GenerateTextureTool.js.map +1 -0
  282. package/dist-lib/esm/tools/builtin/GetSceneInfoTool.d.ts +12 -0
  283. package/dist-lib/esm/tools/builtin/GetSceneInfoTool.d.ts.map +1 -0
  284. package/dist-lib/esm/tools/builtin/GetSceneInfoTool.js +13 -0
  285. package/dist-lib/esm/tools/builtin/GetSceneInfoTool.js.map +1 -0
  286. package/dist-lib/esm/tools/builtin/MergeMeshesTool.d.ts +29 -0
  287. package/dist-lib/esm/tools/builtin/MergeMeshesTool.d.ts.map +1 -0
  288. package/dist-lib/esm/tools/builtin/MergeMeshesTool.js +57 -0
  289. package/dist-lib/esm/tools/builtin/MergeMeshesTool.js.map +1 -0
  290. package/dist-lib/esm/tools/builtin/PlanModelTool.d.ts +88 -0
  291. package/dist-lib/esm/tools/builtin/PlanModelTool.d.ts.map +1 -0
  292. package/dist-lib/esm/tools/builtin/PlanModelTool.js +156 -0
  293. package/dist-lib/esm/tools/builtin/PlanModelTool.js.map +1 -0
  294. package/dist-lib/esm/tools/builtin/RetopologizeMeshTool.d.ts +51 -0
  295. package/dist-lib/esm/tools/builtin/RetopologizeMeshTool.d.ts.map +1 -0
  296. package/dist-lib/esm/tools/builtin/RetopologizeMeshTool.js +117 -0
  297. package/dist-lib/esm/tools/builtin/RetopologizeMeshTool.js.map +1 -0
  298. package/dist-lib/esm/tools/builtin/RigWeightTool.d.ts +56 -0
  299. package/dist-lib/esm/tools/builtin/RigWeightTool.d.ts.map +1 -0
  300. package/dist-lib/esm/tools/builtin/RigWeightTool.js +140 -0
  301. package/dist-lib/esm/tools/builtin/RigWeightTool.js.map +1 -0
  302. package/dist-lib/esm/tools/builtin/SculptMeshTool.d.ts +139 -0
  303. package/dist-lib/esm/tools/builtin/SculptMeshTool.d.ts.map +1 -0
  304. package/dist-lib/esm/tools/builtin/SculptMeshTool.js +256 -0
  305. package/dist-lib/esm/tools/builtin/SculptMeshTool.js.map +1 -0
  306. package/dist-lib/esm/tools/builtin/SeparateMeshTool.d.ts +22 -0
  307. package/dist-lib/esm/tools/builtin/SeparateMeshTool.d.ts.map +1 -0
  308. package/dist-lib/esm/tools/builtin/SeparateMeshTool.js +32 -0
  309. package/dist-lib/esm/tools/builtin/SeparateMeshTool.js.map +1 -0
  310. package/dist-lib/esm/tools/builtin/SolidifyMeshTool.d.ts +31 -0
  311. package/dist-lib/esm/tools/builtin/SolidifyMeshTool.d.ts.map +1 -0
  312. package/dist-lib/esm/tools/builtin/SolidifyMeshTool.js +58 -0
  313. package/dist-lib/esm/tools/builtin/SolidifyMeshTool.js.map +1 -0
  314. package/dist-lib/esm/tools/builtin/SpawnBaseMeshTool.d.ts +67 -0
  315. package/dist-lib/esm/tools/builtin/SpawnBaseMeshTool.d.ts.map +1 -0
  316. package/dist-lib/esm/tools/builtin/SpawnBaseMeshTool.js +106 -0
  317. package/dist-lib/esm/tools/builtin/SpawnBaseMeshTool.js.map +1 -0
  318. package/dist-lib/esm/tools/builtin/SubDSmoothTool.d.ts +24 -0
  319. package/dist-lib/esm/tools/builtin/SubDSmoothTool.d.ts.map +1 -0
  320. package/dist-lib/esm/tools/builtin/SubDSmoothTool.js +38 -0
  321. package/dist-lib/esm/tools/builtin/SubDSmoothTool.js.map +1 -0
  322. package/dist-lib/esm/tools/builtin/SubdivideMeshTool.d.ts +24 -0
  323. package/dist-lib/esm/tools/builtin/SubdivideMeshTool.d.ts.map +1 -0
  324. package/dist-lib/esm/tools/builtin/SubdivideMeshTool.js +40 -0
  325. package/dist-lib/esm/tools/builtin/SubdivideMeshTool.js.map +1 -0
  326. package/dist-lib/esm/tools/builtin/TransformMeshTool.d.ts +79 -0
  327. package/dist-lib/esm/tools/builtin/TransformMeshTool.d.ts.map +1 -0
  328. package/dist-lib/esm/tools/builtin/TransformMeshTool.js +70 -0
  329. package/dist-lib/esm/tools/builtin/TransformMeshTool.js.map +1 -0
  330. package/dist-lib/esm/tools/builtin/UVUnwrapTool.d.ts +49 -0
  331. package/dist-lib/esm/tools/builtin/UVUnwrapTool.d.ts.map +1 -0
  332. package/dist-lib/esm/tools/builtin/UVUnwrapTool.js +108 -0
  333. package/dist-lib/esm/tools/builtin/UVUnwrapTool.js.map +1 -0
  334. package/dist-lib/esm/tools/builtin/VoxelPainterTool.d.ts +61 -0
  335. package/dist-lib/esm/tools/builtin/VoxelPainterTool.d.ts.map +1 -0
  336. package/dist-lib/esm/tools/builtin/VoxelPainterTool.js +154 -0
  337. package/dist-lib/esm/tools/builtin/VoxelPainterTool.js.map +1 -0
  338. package/dist-lib/esm/tools/builtin/index.d.ts +45 -0
  339. package/dist-lib/esm/tools/builtin/index.d.ts.map +1 -0
  340. package/dist-lib/esm/tools/builtin/index.js +45 -0
  341. package/dist-lib/esm/tools/builtin/index.js.map +1 -0
  342. package/dist-lib/esm/tools/editor/AIAgentEditorTool.d.ts +19 -0
  343. package/dist-lib/esm/tools/editor/AIAgentEditorTool.d.ts.map +1 -0
  344. package/dist-lib/esm/tools/editor/AIAgentEditorTool.js +44 -0
  345. package/dist-lib/esm/tools/editor/AIAgentEditorTool.js.map +1 -0
  346. package/dist-lib/esm/tools/editor/AITextureEditorTool.d.ts +16 -0
  347. package/dist-lib/esm/tools/editor/AITextureEditorTool.d.ts.map +1 -0
  348. package/dist-lib/esm/tools/editor/AITextureEditorTool.js +29 -0
  349. package/dist-lib/esm/tools/editor/AITextureEditorTool.js.map +1 -0
  350. package/dist-lib/esm/tools/editor/AbstractEditorTool.d.ts +30 -0
  351. package/dist-lib/esm/tools/editor/AbstractEditorTool.d.ts.map +1 -0
  352. package/dist-lib/esm/tools/editor/AbstractEditorTool.js +57 -0
  353. package/dist-lib/esm/tools/editor/AbstractEditorTool.js.map +1 -0
  354. package/dist-lib/esm/tools/editor/AnimationPlayerEditorTool.d.ts +18 -0
  355. package/dist-lib/esm/tools/editor/AnimationPlayerEditorTool.d.ts.map +1 -0
  356. package/dist-lib/esm/tools/editor/AnimationPlayerEditorTool.js +30 -0
  357. package/dist-lib/esm/tools/editor/AnimationPlayerEditorTool.js.map +1 -0
  358. package/dist-lib/esm/tools/editor/BakingEditorTool.d.ts +22 -0
  359. package/dist-lib/esm/tools/editor/BakingEditorTool.d.ts.map +1 -0
  360. package/dist-lib/esm/tools/editor/BakingEditorTool.js +45 -0
  361. package/dist-lib/esm/tools/editor/BakingEditorTool.js.map +1 -0
  362. package/dist-lib/esm/tools/editor/CSGEditorTool.d.ts +21 -0
  363. package/dist-lib/esm/tools/editor/CSGEditorTool.d.ts.map +1 -0
  364. package/dist-lib/esm/tools/editor/CSGEditorTool.js +43 -0
  365. package/dist-lib/esm/tools/editor/CSGEditorTool.js.map +1 -0
  366. package/dist-lib/esm/tools/editor/CompressModelEditorTool.d.ts +21 -0
  367. package/dist-lib/esm/tools/editor/CompressModelEditorTool.d.ts.map +1 -0
  368. package/dist-lib/esm/tools/editor/CompressModelEditorTool.js +49 -0
  369. package/dist-lib/esm/tools/editor/CompressModelEditorTool.js.map +1 -0
  370. package/dist-lib/esm/tools/editor/CreatePrimitiveEditorTool.d.ts +18 -0
  371. package/dist-lib/esm/tools/editor/CreatePrimitiveEditorTool.d.ts.map +1 -0
  372. package/dist-lib/esm/tools/editor/CreatePrimitiveEditorTool.js +37 -0
  373. package/dist-lib/esm/tools/editor/CreatePrimitiveEditorTool.js.map +1 -0
  374. package/dist-lib/esm/tools/editor/DecalEditorTool.d.ts +18 -0
  375. package/dist-lib/esm/tools/editor/DecalEditorTool.d.ts.map +1 -0
  376. package/dist-lib/esm/tools/editor/DecalEditorTool.js +37 -0
  377. package/dist-lib/esm/tools/editor/DecalEditorTool.js.map +1 -0
  378. package/dist-lib/esm/tools/editor/FacetEditorTool.d.ts +24 -0
  379. package/dist-lib/esm/tools/editor/FacetEditorTool.d.ts.map +1 -0
  380. package/dist-lib/esm/tools/editor/FacetEditorTool.js +81 -0
  381. package/dist-lib/esm/tools/editor/FacetEditorTool.js.map +1 -0
  382. package/dist-lib/esm/tools/editor/MaterialEditorTool.d.ts +19 -0
  383. package/dist-lib/esm/tools/editor/MaterialEditorTool.d.ts.map +1 -0
  384. package/dist-lib/esm/tools/editor/MaterialEditorTool.js +44 -0
  385. package/dist-lib/esm/tools/editor/MaterialEditorTool.js.map +1 -0
  386. package/dist-lib/esm/tools/editor/MeshPropertiesEditorTool.d.ts +18 -0
  387. package/dist-lib/esm/tools/editor/MeshPropertiesEditorTool.d.ts.map +1 -0
  388. package/dist-lib/esm/tools/editor/MeshPropertiesEditorTool.js +38 -0
  389. package/dist-lib/esm/tools/editor/MeshPropertiesEditorTool.js.map +1 -0
  390. package/dist-lib/esm/tools/editor/OutlinerEditorTool.d.ts +18 -0
  391. package/dist-lib/esm/tools/editor/OutlinerEditorTool.d.ts.map +1 -0
  392. package/dist-lib/esm/tools/editor/OutlinerEditorTool.js +35 -0
  393. package/dist-lib/esm/tools/editor/OutlinerEditorTool.js.map +1 -0
  394. package/dist-lib/esm/tools/editor/PathExtrusionEditorTool.d.ts +27 -0
  395. package/dist-lib/esm/tools/editor/PathExtrusionEditorTool.d.ts.map +1 -0
  396. package/dist-lib/esm/tools/editor/PathExtrusionEditorTool.js +73 -0
  397. package/dist-lib/esm/tools/editor/PathExtrusionEditorTool.js.map +1 -0
  398. package/dist-lib/esm/tools/editor/RiggingEditorTool.d.ts +28 -0
  399. package/dist-lib/esm/tools/editor/RiggingEditorTool.d.ts.map +1 -0
  400. package/dist-lib/esm/tools/editor/RiggingEditorTool.js +67 -0
  401. package/dist-lib/esm/tools/editor/RiggingEditorTool.js.map +1 -0
  402. package/dist-lib/esm/tools/editor/SceneEnvironmentEditorTool.d.ts +18 -0
  403. package/dist-lib/esm/tools/editor/SceneEnvironmentEditorTool.d.ts.map +1 -0
  404. package/dist-lib/esm/tools/editor/SceneEnvironmentEditorTool.js +36 -0
  405. package/dist-lib/esm/tools/editor/SceneEnvironmentEditorTool.js.map +1 -0
  406. package/dist-lib/esm/tools/editor/SculptEditorTool.d.ts +29 -0
  407. package/dist-lib/esm/tools/editor/SculptEditorTool.d.ts.map +1 -0
  408. package/dist-lib/esm/tools/editor/SculptEditorTool.js +71 -0
  409. package/dist-lib/esm/tools/editor/SculptEditorTool.js.map +1 -0
  410. package/dist-lib/esm/tools/editor/TextMeshEditorTool.d.ts +17 -0
  411. package/dist-lib/esm/tools/editor/TextMeshEditorTool.d.ts.map +1 -0
  412. package/dist-lib/esm/tools/editor/TextMeshEditorTool.js +31 -0
  413. package/dist-lib/esm/tools/editor/TextMeshEditorTool.js.map +1 -0
  414. package/dist-lib/esm/tools/editor/TextureOptimizerEditorTool.d.ts +18 -0
  415. package/dist-lib/esm/tools/editor/TextureOptimizerEditorTool.d.ts.map +1 -0
  416. package/dist-lib/esm/tools/editor/TextureOptimizerEditorTool.js +29 -0
  417. package/dist-lib/esm/tools/editor/TextureOptimizerEditorTool.js.map +1 -0
  418. package/dist-lib/esm/tools/editor/UVUnwrapEditorTool.d.ts +28 -0
  419. package/dist-lib/esm/tools/editor/UVUnwrapEditorTool.d.ts.map +1 -0
  420. package/dist-lib/esm/tools/editor/UVUnwrapEditorTool.js +71 -0
  421. package/dist-lib/esm/tools/editor/UVUnwrapEditorTool.js.map +1 -0
  422. package/dist-lib/esm/tools/editor/VoxelPainterEditorTool.d.ts +27 -0
  423. package/dist-lib/esm/tools/editor/VoxelPainterEditorTool.d.ts.map +1 -0
  424. package/dist-lib/esm/tools/editor/VoxelPainterEditorTool.js +69 -0
  425. package/dist-lib/esm/tools/editor/VoxelPainterEditorTool.js.map +1 -0
  426. package/dist-lib/esm/tools/editor/aiQuickPrompts.d.ts +31 -0
  427. package/dist-lib/esm/tools/editor/aiQuickPrompts.d.ts.map +1 -0
  428. package/dist-lib/esm/tools/editor/aiQuickPrompts.js +229 -0
  429. package/dist-lib/esm/tools/editor/aiQuickPrompts.js.map +1 -0
  430. package/dist-lib/esm/tools/editor/index.d.ts +33 -0
  431. package/dist-lib/esm/tools/editor/index.d.ts.map +1 -0
  432. package/dist-lib/esm/tools/editor/index.js +55 -0
  433. package/dist-lib/esm/tools/editor/index.js.map +1 -0
  434. package/dist-lib/esm/tools/editor/toolViews.d.ts +11 -0
  435. package/dist-lib/esm/tools/editor/toolViews.d.ts.map +1 -0
  436. package/dist-lib/esm/tools/editor/toolViews.js +54 -0
  437. package/dist-lib/esm/tools/editor/toolViews.js.map +1 -0
  438. package/dist-lib/esm/tools/editorTools.d.ts +6 -0
  439. package/dist-lib/esm/tools/editorTools.d.ts.map +1 -0
  440. package/dist-lib/esm/tools/editorTools.js +6 -0
  441. package/dist-lib/esm/tools/editorTools.js.map +1 -0
  442. package/dist-lib/esm/tools/index.d.ts +9 -0
  443. package/dist-lib/esm/tools/index.d.ts.map +1 -0
  444. package/dist-lib/esm/tools/index.js +9 -0
  445. package/dist-lib/esm/tools/index.js.map +1 -0
  446. package/dist-lib/esm/tools/textureUtils.d.ts +19 -0
  447. package/dist-lib/esm/tools/textureUtils.d.ts.map +1 -0
  448. package/dist-lib/esm/tools/textureUtils.js +289 -0
  449. package/dist-lib/esm/tools/textureUtils.js.map +1 -0
  450. package/dist-lib/esm/types.d.ts +165 -0
  451. package/dist-lib/esm/types.d.ts.map +1 -0
  452. package/dist-lib/esm/types.js +2 -0
  453. package/dist-lib/esm/types.js.map +1 -0
  454. package/dist-lib/esm/uv/UVUnwrapController.d.ts +109 -0
  455. package/dist-lib/esm/uv/UVUnwrapController.d.ts.map +1 -0
  456. package/dist-lib/esm/uv/UVUnwrapController.js +1023 -0
  457. package/dist-lib/esm/uv/UVUnwrapController.js.map +1 -0
  458. package/dist-lib/esm/voxel/CustomVoxelMesher.d.ts +16 -0
  459. package/dist-lib/esm/voxel/CustomVoxelMesher.d.ts.map +1 -0
  460. package/dist-lib/esm/voxel/CustomVoxelMesher.js +170 -0
  461. package/dist-lib/esm/voxel/CustomVoxelMesher.js.map +1 -0
  462. package/dist-lib/esm/voxel/TextureAtlasManager.d.ts +55 -0
  463. package/dist-lib/esm/voxel/TextureAtlasManager.d.ts.map +1 -0
  464. package/dist-lib/esm/voxel/TextureAtlasManager.js +631 -0
  465. package/dist-lib/esm/voxel/TextureAtlasManager.js.map +1 -0
  466. package/dist-lib/esm/voxel/VoxelPainterController.d.ts +101 -0
  467. package/dist-lib/esm/voxel/VoxelPainterController.d.ts.map +1 -0
  468. package/dist-lib/esm/voxel/VoxelPainterController.js +672 -0
  469. package/dist-lib/esm/voxel/VoxelPainterController.js.map +1 -0
  470. package/dist-lib/esm/voxel/index.d.ts +5 -0
  471. package/dist-lib/esm/voxel/index.d.ts.map +1 -0
  472. package/dist-lib/esm/voxel/index.js +5 -0
  473. package/dist-lib/esm/voxel/index.js.map +1 -0
  474. package/dist-lib/esm/voxel/types.d.ts +79 -0
  475. package/dist-lib/esm/voxel/types.d.ts.map +1 -0
  476. package/dist-lib/esm/voxel/types.js +2 -0
  477. package/dist-lib/esm/voxel/types.js.map +1 -0
  478. package/dist-lib/esm/web-component/MeshEditorElement.d.ts +104 -0
  479. package/dist-lib/esm/web-component/MeshEditorElement.d.ts.map +1 -0
  480. package/dist-lib/esm/web-component/MeshEditorElement.js +247 -0
  481. package/dist-lib/esm/web-component/MeshEditorElement.js.map +1 -0
  482. package/dist-lib/esm/web-component/index.d.ts +2 -0
  483. package/dist-lib/esm/web-component/index.d.ts.map +1 -0
  484. package/dist-lib/esm/web-component/index.js +2 -0
  485. package/dist-lib/esm/web-component/index.js.map +1 -0
  486. package/dist-lib/index.umd.js +3 -0
  487. package/dist-lib/mesheditor.css +2 -0
  488. package/dist-lib/standalone/mesheditor-element.bundle.js +3 -0
  489. package/package.json +113 -4
  490. package/skills/README.md +48 -0
  491. package/skills/figure-sculptor.md +297 -0
  492. package/skills/image-to-mesh.md +18 -0
  493. package/skills/mesh-updater.md +27 -0
  494. package/skills/neural-3d-generator.md +53 -0
  495. package/skills/procedural-modeler.md +267 -0
  496. package/skills/voxel-painter.md +21 -0
  497. package/src/mesheditor.css +6477 -0
@@ -0,0 +1,832 @@
1
+ import { Mesh, MeshBuilder, Vector3, VertexData, } from '@babylonjs/core';
2
+ import earcut from 'earcut';
3
+ import { createRoundedBoxMesh } from './roundedBox';
4
+ function makeUpdatableMerged(parts, name, scene) {
5
+ const valid = parts.filter((p) => p && !p.isDisposed() && p.getTotalVertices() > 0);
6
+ if (valid.length === 0) {
7
+ return MeshBuilder.CreateBox(name, { size: 0.1, updatable: true }, scene);
8
+ }
9
+ for (const p of valid) {
10
+ p.computeWorldMatrix(true);
11
+ }
12
+ const merged = valid.length === 1
13
+ ? valid[0]
14
+ : Mesh.MergeMeshes(valid, true, true, undefined, false, false);
15
+ if (!merged) {
16
+ return valid[0];
17
+ }
18
+ merged.name = name;
19
+ const vd = VertexData.ExtractFromMesh(merged);
20
+ vd.applyToMesh(merged, true);
21
+ return merged;
22
+ }
23
+ /**
24
+ * Generates 2D contour points (x, z in ExtrudePolygon's XZ plane, mapping to wall X and wall Y)
25
+ * for a window/door opening.
26
+ */
27
+ function buildOpeningContour2D(op, wallW, wallH) {
28
+ const type = (op.type || 'rect').toLowerCase();
29
+ const w = Math.max(0.1, Math.min(wallW - 0.1, Number(op.width ?? 0.9)));
30
+ const h = Math.max(0.1, Math.min(wallH - 0.05, Number(op.height ?? 1.4)));
31
+ const cx = Math.max(-wallW * 0.5 + w * 0.5 + 0.03, Math.min(wallW * 0.5 - w * 0.5 - 0.03, Number(op.x ?? 0)));
32
+ const y0 = Math.max(0.005, Math.min(wallH - h - 0.03, Number(op.y ?? 0)));
33
+ const hw = w * 0.5;
34
+ const pts = [];
35
+ if (type === 'round') {
36
+ const r = Math.min(hw, h * 0.5);
37
+ const cy = y0 + h * 0.5;
38
+ const segs = 16;
39
+ for (let i = 0; i < segs; i++) {
40
+ const a = (i / segs) * Math.PI * 2;
41
+ pts.push(new Vector3(cx + Math.cos(a) * r, 0, cy + Math.sin(a) * r));
42
+ }
43
+ return pts;
44
+ }
45
+ if (type === 'arch') {
46
+ const archRise = Math.min(h * 0.6, Number(op.archRise ?? hw));
47
+ const springY = y0 + Math.max(0.05, h - archRise);
48
+ pts.push(new Vector3(cx - hw, 0, y0));
49
+ pts.push(new Vector3(cx + hw, 0, y0));
50
+ pts.push(new Vector3(cx + hw, 0, springY));
51
+ const segs = 12;
52
+ for (let i = 1; i < segs; i++) {
53
+ const t = (i / segs) * Math.PI;
54
+ pts.push(new Vector3(cx + Math.cos(t) * hw, 0, springY + Math.sin(t) * archRise));
55
+ }
56
+ pts.push(new Vector3(cx - hw, 0, springY));
57
+ return pts;
58
+ }
59
+ // Rectangular opening
60
+ pts.push(new Vector3(cx - hw, 0, y0));
61
+ pts.push(new Vector3(cx + hw, 0, y0));
62
+ pts.push(new Vector3(cx + hw, 0, y0 + h));
63
+ pts.push(new Vector3(cx - hw, 0, y0 + h));
64
+ return pts;
65
+ }
66
+ /**
67
+ * Builds a parametric architectural wall standing on Y = 0, centered on X = 0, Z = 0,
68
+ * with cleanly cut openings, optional window/door frames, plinth, and cornice.
69
+ */
70
+ export function buildWallMesh(scene, name, opts = {}) {
71
+ const width = Math.max(0.2, Number(opts.width ?? 4.0));
72
+ const height = Math.max(0.2, Number(opts.height ?? 3.0));
73
+ const thickness = Math.max(0.05, Number(opts.thickness ?? 0.25));
74
+ const openings = Array.isArray(opts.openings) ? opts.openings : [];
75
+ const parts = [];
76
+ if (openings.length === 0) {
77
+ const bevel = opts.bevelRadius !== undefined ? Number(opts.bevelRadius) : Math.min(thickness * 0.08, 0.02);
78
+ const box = createRoundedBoxMesh(`${name}_body`, { width, height, depth: thickness, radius: bevel, segments: 2 }, scene);
79
+ box.position.set(0, height * 0.5, 0);
80
+ box.bakeCurrentTransformIntoVertices();
81
+ parts.push(box);
82
+ }
83
+ else {
84
+ const hw = width * 0.5;
85
+ const outer = [
86
+ new Vector3(-hw, 0, 0),
87
+ new Vector3(hw, 0, 0),
88
+ new Vector3(hw, 0, height),
89
+ new Vector3(-hw, 0, height),
90
+ ];
91
+ const holes = openings.map((op) => buildOpeningContour2D(op, width, height));
92
+ // ExtrudePolygon extrudes downward along -Y in local space from Y=0 to Y=-depth
93
+ const poly = MeshBuilder.ExtrudePolygon(`${name}_poly`, {
94
+ shape: outer,
95
+ holes,
96
+ depth: thickness,
97
+ sideOrientation: Mesh.DOUBLESIDE,
98
+ updatable: true,
99
+ }, scene, earcut);
100
+ // Rotate -90 deg around X so local Z (0..height) maps to world +Y (0..height),
101
+ // and local Y (-thickness..0) maps to world Z (-thickness/2..+thickness/2)
102
+ poly.rotation.x = -Math.PI / 2;
103
+ poly.position.set(0, 0, -thickness * 0.5);
104
+ poly.bakeCurrentTransformIntoVertices();
105
+ parts.push(poly);
106
+ // Optional frames around openings
107
+ for (let i = 0; i < openings.length; i++) {
108
+ const op = openings[i];
109
+ if (op.frame === false)
110
+ continue;
111
+ const contour = holes[i];
112
+ if (!contour || contour.length < 3)
113
+ continue;
114
+ const fw = Math.max(0.02, Number(op.frameWidth ?? 0.06));
115
+ const fd = Math.max(thickness + 0.02, Number(op.frameDepth ?? thickness + 0.05));
116
+ for (let j = 0; j < contour.length; j++) {
117
+ const p0 = contour[j];
118
+ const p1 = contour[(j + 1) % contour.length];
119
+ // Skip bottom sill for doors touching ground (y <= 0.02)
120
+ if (Math.abs(p0.z) < 0.02 && Math.abs(p1.z) < 0.02)
121
+ continue;
122
+ const yStart = p0.z < 0.02 ? fw * 0.25 : p0.z;
123
+ const yEnd = p1.z < 0.02 ? fw * 0.25 : p1.z;
124
+ const dx = p1.x - p0.x;
125
+ const dy = yEnd - yStart;
126
+ const segLen = Math.hypot(dx, dy);
127
+ if (segLen < 1e-3)
128
+ continue;
129
+ const bar = MeshBuilder.CreateBox(`${name}_frame_${i}_${j}`, { width: segLen + fw * 0.4, height: fw, depth: fd }, scene);
130
+ bar.rotation.z = Math.atan2(dy, dx);
131
+ bar.position.set((p0.x + p1.x) * 0.5, (yStart + yEnd) * 0.5, 0);
132
+ bar.bakeCurrentTransformIntoVertices();
133
+ parts.push(bar);
134
+ }
135
+ }
136
+ }
137
+ // Optional plinth band at base
138
+ const plinthH = Number(opts.plinthHeight ?? 0);
139
+ if (plinthH > 0.01 && openings.every((o) => (o.y ?? 1) > plinthH)) {
140
+ const plinth = createRoundedBoxMesh(`${name}_plinth`, { width: width + 0.06, height: plinthH, depth: thickness + 0.06, radius: 0.015, segments: 2 }, scene);
141
+ plinth.position.set(0, plinthH * 0.5, 0);
142
+ plinth.bakeCurrentTransformIntoVertices();
143
+ parts.push(plinth);
144
+ }
145
+ // Optional cornice band at top
146
+ const corniceH = Number(opts.corniceHeight ?? 0);
147
+ if (corniceH > 0.01) {
148
+ const cornice = createRoundedBoxMesh(`${name}_cornice`, { width: width + 0.1, height: corniceH, depth: thickness + 0.1, radius: 0.02, segments: 2 }, scene);
149
+ cornice.position.set(0, height - corniceH * 0.5, 0);
150
+ cornice.bakeCurrentTransformIntoVertices();
151
+ parts.push(cornice);
152
+ }
153
+ return makeUpdatableMerged(parts, name, scene);
154
+ }
155
+ /**
156
+ * Builds a freestanding architectural arch / portal standing on Y = 0.
157
+ */
158
+ export function buildArchMesh(scene, name, opts = {}) {
159
+ const style = (opts.style || 'round').toLowerCase();
160
+ const span = Math.max(0.3, Number(opts.span ?? 2.0));
161
+ const halfSpan = span * 0.5;
162
+ const pierHeight = Math.max(0, Number(opts.pierHeight ?? 1.8));
163
+ const pierWidth = Math.max(0.1, Number(opts.pierWidth ?? 0.35));
164
+ const thickness = Math.max(0.08, Number(opts.thickness ?? pierWidth));
165
+ const depth = Math.max(0.1, Number(opts.depth ?? 0.4));
166
+ const rise = Math.max(0.1, Number(opts.rise ?? (style === 'pointed' ? span * 0.65 : style === 'segmental' ? span * 0.28 : halfSpan)));
167
+ const segs = Math.max(6, Math.min(48, Math.round(opts.segments ?? 16)));
168
+ const parts = [];
169
+ // 1. Left and Right Piers + Plinth Bases + Impost Caps
170
+ if (pierHeight > 0.02) {
171
+ for (const side of [-1, 1]) {
172
+ const px = side * (halfSpan + pierWidth * 0.5);
173
+ const pier = createRoundedBoxMesh(`${name}_pier_${side}`, { width: pierWidth, height: pierHeight, depth, radius: Math.min(0.02, pierWidth * 0.08), segments: 2 }, scene);
174
+ pier.position.set(px, pierHeight * 0.5, 0);
175
+ pier.bakeCurrentTransformIntoVertices();
176
+ parts.push(pier);
177
+ // Base plinth
178
+ const baseH = Math.min(0.16, pierHeight * 0.12);
179
+ const base = createRoundedBoxMesh(`${name}_pier_base_${side}`, { width: pierWidth + 0.08, height: baseH, depth: depth + 0.08, radius: 0.018, segments: 2 }, scene);
180
+ base.position.set(px, baseH * 0.5, 0);
181
+ base.bakeCurrentTransformIntoVertices();
182
+ parts.push(base);
183
+ // Impost cap at spring line
184
+ if (opts.impostCap !== false) {
185
+ const capH = Math.min(0.12, pierHeight * 0.08 + 0.04);
186
+ const cap = createRoundedBoxMesh(`${name}_impost_${side}`, { width: pierWidth + 0.08, height: capH, depth: depth + 0.08, radius: 0.018, segments: 2 }, scene);
187
+ cap.position.set(px, pierHeight - capH * 0.5, 0);
188
+ cap.bakeCurrentTransformIntoVertices();
189
+ parts.push(cap);
190
+ }
191
+ }
192
+ }
193
+ // 2. Arch Ring (voussoir band above pierHeight)
194
+ const evalInnerArch = (t) => {
195
+ if (style === 'flat') {
196
+ const x = halfSpan * (1 - 2 * t);
197
+ return { x, y: pierHeight, nx: 0, ny: 1 };
198
+ }
199
+ if (style === 'pointed') {
200
+ // Gothic lancet arch: two intersecting arcs meeting at apex (t = 0.5)
201
+ if (t <= 0.5) {
202
+ const u = t * 2; // 0 (right spring) to 1 (apex)
203
+ const angle = (u * Math.PI) / 2;
204
+ const x = halfSpan * Math.cos(angle);
205
+ const y = pierHeight + rise * Math.sin(angle);
206
+ const nx = Math.cos(angle);
207
+ const ny = Math.sin(angle);
208
+ return { x, y, nx, ny };
209
+ }
210
+ else {
211
+ const u = (1 - t) * 2; // 1 (apex) to 0 (left spring)
212
+ const angle = (u * Math.PI) / 2;
213
+ const x = -halfSpan * Math.cos(angle);
214
+ const y = pierHeight + rise * Math.sin(angle);
215
+ const nx = -Math.cos(angle);
216
+ const ny = Math.sin(angle);
217
+ return { x, y, nx, ny };
218
+ }
219
+ }
220
+ if (style === 'horseshoe') {
221
+ const startAngle = -0.22 * Math.PI;
222
+ const endAngle = 1.22 * Math.PI;
223
+ const angle = startAngle + t * (endAngle - startAngle);
224
+ const x = Math.cos(angle) * halfSpan;
225
+ const y = pierHeight + rise * 0.35 + Math.sin(angle) * rise;
226
+ return { x, y, nx: Math.cos(angle), ny: Math.sin(angle) };
227
+ }
228
+ // Round or segmental arch
229
+ const angle = t * Math.PI;
230
+ const x = Math.cos(angle) * halfSpan;
231
+ const y = pierHeight + Math.sin(angle) * rise;
232
+ const len = Math.hypot(Math.cos(angle) / halfSpan, Math.sin(angle) / rise) || 1;
233
+ const nx = Math.cos(angle) / halfSpan / len;
234
+ const ny = Math.sin(angle) / rise / len;
235
+ return { x, y, nx, ny };
236
+ };
237
+ const innerPts = [];
238
+ const outerPts = [];
239
+ for (let i = 0; i <= segs; i++) {
240
+ const t = i / segs;
241
+ const p = evalInnerArch(t);
242
+ innerPts.push(new Vector3(p.x, 0, p.y));
243
+ outerPts.push(new Vector3(p.x + p.nx * thickness, 0, p.y + p.ny * thickness));
244
+ }
245
+ const ringContour = [...innerPts, ...outerPts.reverse()];
246
+ const ringMesh = MeshBuilder.ExtrudePolygon(`${name}_ring`, {
247
+ shape: ringContour,
248
+ depth,
249
+ sideOrientation: Mesh.DOUBLESIDE,
250
+ updatable: true,
251
+ }, scene, earcut);
252
+ ringMesh.rotation.x = -Math.PI / 2;
253
+ ringMesh.position.set(0, 0, -depth * 0.5);
254
+ ringMesh.bakeCurrentTransformIntoVertices();
255
+ parts.push(ringMesh);
256
+ // 3. Optional Keystone at apex
257
+ if (opts.keystone !== false) {
258
+ const apex = evalInnerArch(0.5);
259
+ const keyH = thickness * 1.22;
260
+ const keyW = Math.max(0.1, span * 0.11);
261
+ const keystone = createRoundedBoxMesh(`${name}_keystone`, { width: keyW, height: keyH, depth: depth + 0.06, radius: 0.015, segments: 2 }, scene);
262
+ keystone.position.set(0, apex.y + thickness * 0.52, 0);
263
+ keystone.bakeCurrentTransformIntoVertices();
264
+ parts.push(keystone);
265
+ }
266
+ return makeUpdatableMerged(parts, name, scene);
267
+ }
268
+ /**
269
+ * Builds a classical or modern column standing on Y = 0 up to Y = height,
270
+ * with plinth, torus base, fluted + entasis shaft, necking ring, echinus capital, and abacus.
271
+ */
272
+ export function buildColumnMesh(scene, name, opts = {}) {
273
+ const order = (opts.order || 'doric').toLowerCase();
274
+ const totalHeight = Math.max(0.4, Number(opts.height ?? 3.2));
275
+ const baseRadius = Math.max(0.05, Number(opts.radius ?? 0.24));
276
+ const taper = Math.max(0.5, Math.min(1.0, Number(opts.taper ?? (order === 'modern' ? 1.0 : 0.85))));
277
+ const entasis = Math.max(0, Math.min(0.15, Number(opts.entasis ?? (order === 'modern' ? 0 : 0.025))));
278
+ const defaultFlutes = order === 'tuscan' || order === 'modern' ? 0 : order === 'doric' ? 20 : 24;
279
+ const flutes = Math.max(0, Math.min(40, Math.round(opts.flutes ?? defaultFlutes)));
280
+ const fluteDepth = Math.max(0, Number(opts.fluteDepth ?? baseRadius * 0.065));
281
+ const radialSegs = Math.max(16, Math.min(96, flutes > 0 ? flutes * 4 : Math.round(opts.radialSegments ?? 28)));
282
+ const parts = [];
283
+ const hasPlinth = order !== 'modern';
284
+ const baseHeight = hasPlinth ? totalHeight * 0.09 : 0;
285
+ const capHeight = order !== 'modern' ? totalHeight * 0.1 : 0;
286
+ const shaftY0 = baseHeight;
287
+ const shaftY1 = totalHeight - capHeight;
288
+ const shaftHeight = Math.max(0.1, shaftY1 - shaftY0);
289
+ // 1. Plinth & Molded Base
290
+ if (hasPlinth) {
291
+ const plinthH = baseHeight * 0.45;
292
+ const plinthW = baseRadius * 2.65;
293
+ const plinth = createRoundedBoxMesh(`${name}_plinth`, { width: plinthW, height: plinthH, depth: plinthW, radius: 0.015, segments: 2 }, scene);
294
+ plinth.position.set(0, plinthH * 0.5, 0);
295
+ plinth.bakeCurrentTransformIntoVertices();
296
+ parts.push(plinth);
297
+ const torusBaseProfile = [
298
+ new Vector3(baseRadius * 1.25, plinthH, 0),
299
+ new Vector3(baseRadius * 1.32, plinthH + baseHeight * 0.2, 0),
300
+ new Vector3(baseRadius * 1.15, plinthH + baseHeight * 0.4, 0),
301
+ new Vector3(baseRadius * 1.20, plinthH + baseHeight * 0.65, 0),
302
+ new Vector3(baseRadius, shaftY0, 0),
303
+ ];
304
+ const baseLathe = MeshBuilder.CreateLathe(`${name}_base_torus`, { shape: torusBaseProfile, tessellation: Math.min(36, radialSegs), sideOrientation: Mesh.FRONTSIDE }, scene);
305
+ parts.push(baseLathe);
306
+ }
307
+ // 2. Parametric Fluted & Entasis Shaft
308
+ const vSegs = 24;
309
+ const shaftPos = [];
310
+ const shaftNorm = [];
311
+ const shaftUV = [];
312
+ const shaftIdx = [];
313
+ for (let iv = 0; iv <= vSegs; iv++) {
314
+ const v = iv / vSegs;
315
+ const y = shaftY0 + v * shaftHeight;
316
+ // Classical entasis peaks around 1/3 up the shaft
317
+ const entasisBulge = Math.sin(v * Math.PI) * entasis * baseRadius;
318
+ const ringR = baseRadius * (1 - (1 - taper) * v) + entasisBulge;
319
+ // Fade flutes out smoothly at bottom and top 8% with smoothstep
320
+ const fade = 0.08;
321
+ let fluteEnvelope = 1.0;
322
+ if (v < fade) {
323
+ const t = v / fade;
324
+ fluteEnvelope = t * t * (3 - 2 * t);
325
+ }
326
+ else if (v > 1 - fade) {
327
+ const t = (1 - v) / fade;
328
+ fluteEnvelope = t * t * (3 - 2 * t);
329
+ }
330
+ if (flutes === 0)
331
+ fluteEnvelope = 0;
332
+ for (let iu = 0; iu <= radialSegs; iu++) {
333
+ const u = iu / radialSegs;
334
+ const theta = u * Math.PI * 2;
335
+ let r = ringR;
336
+ if (flutes > 0) {
337
+ const fluteWave = Math.pow(Math.max(0, Math.sin(theta * flutes)), 0.65);
338
+ r -= fluteDepth * fluteEnvelope * fluteWave;
339
+ }
340
+ const x = Math.cos(theta) * r;
341
+ const z = Math.sin(theta) * r;
342
+ shaftPos.push(x, y, z);
343
+ shaftUV.push(u, v);
344
+ }
345
+ }
346
+ const stride = radialSegs + 1;
347
+ for (let iv = 0; iv < vSegs; iv++) {
348
+ for (let iu = 0; iu < radialSegs; iu++) {
349
+ const i00 = iv * stride + iu;
350
+ const i10 = iv * stride + (iu + 1);
351
+ const i01 = (iv + 1) * stride + iu;
352
+ const i11 = (iv + 1) * stride + (iu + 1);
353
+ // Correct outward normal winding:
354
+ shaftIdx.push(i00, i10, i11, i00, i11, i01);
355
+ }
356
+ }
357
+ const shaftMesh = new Mesh(`${name}_shaft`, scene);
358
+ const shaftVD = new VertexData();
359
+ const shaftNormalsComputed = new Float32Array(shaftPos.length);
360
+ VertexData.ComputeNormals(shaftPos, shaftIdx, shaftNormalsComputed);
361
+ shaftVD.positions = shaftPos;
362
+ shaftVD.indices = shaftIdx;
363
+ shaftVD.normals = shaftNormalsComputed;
364
+ shaftVD.uvs = shaftUV;
365
+ shaftVD.applyToMesh(shaftMesh, true);
366
+ parts.push(shaftMesh);
367
+ // 3. Capital (Astragal necking + Echinus flare + Abacus slab + Order ornaments)
368
+ if (capHeight > 0) {
369
+ const topR = baseRadius * taper;
370
+ const abacusH = capHeight * 0.35;
371
+ const echinusTopY = totalHeight - abacusH;
372
+ const capProfile = [
373
+ new Vector3(topR * 1.05, shaftY1, 0),
374
+ new Vector3(topR * 1.02, shaftY1 + capHeight * 0.15, 0),
375
+ new Vector3(topR * 1.25, shaftY1 + capHeight * 0.45, 0),
376
+ new Vector3(topR * (order === 'corinthian' ? 1.45 : 1.35), echinusTopY, 0),
377
+ ];
378
+ const echinus = MeshBuilder.CreateLathe(`${name}_echinus`, { shape: capProfile, tessellation: Math.min(36, radialSegs), sideOrientation: Mesh.FRONTSIDE }, scene);
379
+ parts.push(echinus);
380
+ const abacusW = topR * 2.85;
381
+ const abacus = createRoundedBoxMesh(`${name}_abacus`, { width: abacusW, height: abacusH, depth: abacusW, radius: 0.015, segments: 2 }, scene);
382
+ abacus.position.set(0, totalHeight - abacusH * 0.5, 0);
383
+ abacus.bakeCurrentTransformIntoVertices();
384
+ parts.push(abacus);
385
+ if (order === 'ionic') {
386
+ // Proportional Ionic volute scroll discs under the abacus
387
+ const voluteR = capHeight * 0.32;
388
+ const voluteThick = topR * 0.45;
389
+ for (const sx of [-1, 1]) {
390
+ const volute = MeshBuilder.CreateCylinder(`${name}_volute_${sx}`, {
391
+ height: voluteThick,
392
+ diameter: voluteR * 2,
393
+ tessellation: 24,
394
+ }, scene);
395
+ volute.rotation.x = Math.PI / 2;
396
+ volute.position.set(sx * (topR * 1.05), echinusTopY - voluteR * 0.65, 0);
397
+ volute.bakeCurrentTransformIntoVertices();
398
+ parts.push(volute);
399
+ }
400
+ }
401
+ }
402
+ return makeUpdatableMerged(parts, name, scene);
403
+ }
404
+ /**
405
+ * Generates 2D cross-section profile points (x = outward projection, y = vertical height) for moldings.
406
+ */
407
+ function getMoldingProfilePoints(preset, width, height, custom) {
408
+ if (custom && custom.length >= 3) {
409
+ return custom.map((p) => Array.isArray(p) ? [Number(p[0]) || 0, Number(p[1]) || 0] : [Number(p.x) || 0, Number(p.y) || 0]);
410
+ }
411
+ const w = width;
412
+ const h = height;
413
+ switch (preset) {
414
+ case 'cove':
415
+ return [
416
+ [0, 0],
417
+ [w * 0.3, 0],
418
+ [w * 0.45, h * 0.35],
419
+ [w * 0.72, h * 0.68],
420
+ [w, h * 0.85],
421
+ [w, h],
422
+ [0, h],
423
+ ];
424
+ case 'torus':
425
+ return [
426
+ [0, 0],
427
+ [w * 0.65, 0],
428
+ [w * 0.92, h * 0.25],
429
+ [w, h * 0.5],
430
+ [w * 0.92, h * 0.75],
431
+ [w * 0.65, h],
432
+ [0, h],
433
+ ];
434
+ case 'baseboard':
435
+ return [
436
+ [0, 0],
437
+ [w, 0],
438
+ [w, h * 0.7],
439
+ [w * 0.8, h * 0.85],
440
+ [w * 0.5, h * 0.94],
441
+ [0, h],
442
+ ];
443
+ case 'stepped':
444
+ return [
445
+ [0, 0],
446
+ [w * 0.4, 0],
447
+ [w * 0.4, h * 0.35],
448
+ [w * 0.7, h * 0.35],
449
+ [w * 0.7, h * 0.7],
450
+ [w, h * 0.7],
451
+ [w, h],
452
+ [0, h],
453
+ ];
454
+ case 'ogee':
455
+ case 'cyma_recta':
456
+ case 'cornice':
457
+ default:
458
+ return [
459
+ [0, 0],
460
+ [w * 0.35, 0],
461
+ [w * 0.35, h * 0.2],
462
+ [w * 0.62, h * 0.38],
463
+ [w * 0.82, h * 0.65],
464
+ [w, h * 0.82],
465
+ [w, h],
466
+ [0, h],
467
+ ];
468
+ }
469
+ }
470
+ /**
471
+ * Sweeps a 2D molding profile along a 3D polyline with exact tangent-bisector mitered corners
472
+ * so rectangular frames, room baseboards, and roof cornices have sharp, distortion-free corners.
473
+ */
474
+ export function buildMoldingMesh(scene, name, opts) {
475
+ const rawPath = Array.isArray(opts.path) ? opts.path : [];
476
+ const pathPts = rawPath.map((p) => Array.isArray(p)
477
+ ? new Vector3(Number(p[0]) || 0, Number(p[1]) || 0, Number(p[2]) || 0)
478
+ : new Vector3(Number(p?.x) || 0, Number(p?.y) || 0, Number(p?.z) || 0));
479
+ if (pathPts.length < 2) {
480
+ throw new Error('modeler_create_molding requires at least 2 path points.');
481
+ }
482
+ const closed = !!opts.closed;
483
+ const width = Math.max(0.01, Number(opts.width ?? 0.15));
484
+ const height = Math.max(0.01, Number(opts.height ?? 0.18));
485
+ const profile = getMoldingProfilePoints(opts.profile || 'cornice', width, height, opts.profilePoints);
486
+ const profCount = profile.length;
487
+ const nPts = pathPts.length;
488
+ // Compute segment tangents and outward horizontal normals
489
+ const segTangents = [];
490
+ const segCount = closed ? nPts : nPts - 1;
491
+ for (let i = 0; i < segCount; i++) {
492
+ const p0 = pathPts[i];
493
+ const p1 = pathPts[(i + 1) % nPts];
494
+ const dir = p1.subtract(p0);
495
+ if (dir.lengthSquared() < 1e-8) {
496
+ segTangents.push(new Vector3(1, 0, 0));
497
+ }
498
+ else {
499
+ segTangents.push(dir.normalize());
500
+ }
501
+ }
502
+ const up = Vector3.Up();
503
+ const positions = [];
504
+ const uvs = [];
505
+ const indices = [];
506
+ let accumLen = 0;
507
+ for (let i = 0; i < nPts; i++) {
508
+ if (i > 0) {
509
+ accumLen += Vector3.Distance(pathPts[i - 1], pathPts[i]);
510
+ }
511
+ const tPrev = closed ? segTangents[(i - 1 + segCount) % segCount] : segTangents[Math.max(0, i - 1)];
512
+ const tNext = closed ? segTangents[i % segCount] : segTangents[Math.min(segCount - 1, i)];
513
+ // Outward right-hand normal in XZ plane: (t.z, 0, -t.x) or up x tangent
514
+ let nPrev = Vector3.Cross(up, tPrev);
515
+ if (nPrev.lengthSquared() < 1e-6)
516
+ nPrev = new Vector3(1, 0, 0);
517
+ else
518
+ nPrev.normalize();
519
+ let nNext = Vector3.Cross(up, tNext);
520
+ if (nNext.lengthSquared() < 1e-6)
521
+ nNext = new Vector3(1, 0, 0);
522
+ else
523
+ nNext.normalize();
524
+ let miter = nPrev.add(nNext);
525
+ if (miter.lengthSquared() < 1e-6) {
526
+ miter = nNext.clone();
527
+ }
528
+ else {
529
+ miter.normalize();
530
+ }
531
+ const dot = Math.max(0.25, Vector3.Dot(miter, nNext));
532
+ const miterScale = Math.min(2.5, 1.0 / dot);
533
+ const outVec = miter.scale(miterScale);
534
+ const pt = pathPts[i];
535
+ for (let j = 0; j < profCount; j++) {
536
+ const [px, py] = profile[j];
537
+ const vx = pt.x + outVec.x * px;
538
+ const vy = pt.y + py;
539
+ const vz = pt.z + outVec.z * px;
540
+ positions.push(vx, vy, vz);
541
+ uvs.push(accumLen, j / profCount);
542
+ }
543
+ }
544
+ const ringCount = closed ? nPts : nPts - 1;
545
+ for (let i = 0; i < ringCount; i++) {
546
+ const r0 = i * profCount;
547
+ const r1 = ((i + 1) % nPts) * profCount;
548
+ for (let j = 0; j < profCount; j++) {
549
+ const jNext = (j + 1) % profCount;
550
+ const a = r0 + j;
551
+ const b = r1 + j;
552
+ const c = r1 + jNext;
553
+ const d = r0 + jNext;
554
+ indices.push(a, c, b, a, d, c);
555
+ }
556
+ }
557
+ // Cap open ends
558
+ if (!closed && profCount >= 3) {
559
+ const startBase = 0;
560
+ const endBase = (nPts - 1) * profCount;
561
+ for (let j = 1; j < profCount - 1; j++) {
562
+ indices.push(startBase, startBase + j + 1, startBase + j);
563
+ indices.push(endBase, endBase + j, endBase + j + 1);
564
+ }
565
+ }
566
+ const mesh = new Mesh(name, scene);
567
+ const vd = new VertexData();
568
+ const normals = new Float32Array(positions.length);
569
+ VertexData.ComputeNormals(positions, indices, normals);
570
+ vd.positions = positions;
571
+ vd.indices = indices;
572
+ vd.normals = normals;
573
+ vd.uvs = uvs;
574
+ vd.applyToMesh(mesh, true);
575
+ return mesh;
576
+ }
577
+ /**
578
+ * Builds straight, spiral, or L-shaped staircases standing on Y = 0, with beveled treads,
579
+ * stringers/risers, and optional railings.
580
+ */
581
+ export function buildStairsMesh(scene, name, opts = {}) {
582
+ const style = (opts.style || 'straight').toLowerCase();
583
+ const steps = Math.max(2, Math.min(80, Math.round(opts.steps ?? 10)));
584
+ const width = Math.max(0.3, Number(opts.width ?? 1.2));
585
+ const stepRise = opts.stepRise !== undefined
586
+ ? Math.max(0.05, Number(opts.stepRise))
587
+ : opts.height !== undefined
588
+ ? Math.max(0.05, Number(opts.height) / steps)
589
+ : 0.18;
590
+ const stepRun = opts.stepRun !== undefined
591
+ ? Math.max(0.08, Number(opts.stepRun))
592
+ : opts.length !== undefined
593
+ ? Math.max(0.08, Number(opts.length) / steps)
594
+ : 0.28;
595
+ const nosing = Math.max(0, Number(opts.nosing ?? 0.025));
596
+ const railingOpt = opts.railing === true
597
+ ? 'both'
598
+ : opts.railing === false || !opts.railing
599
+ ? 'none'
600
+ : String(opts.railing).toLowerCase();
601
+ const railingHeight = Math.max(0.4, Number(opts.railingHeight ?? 0.9));
602
+ const parts = [];
603
+ if (style === 'spiral') {
604
+ const innerR = Math.max(0.08, Number(opts.innerRadius ?? 0.2));
605
+ const outerR = innerR + width;
606
+ const totalAngleRad = ((Number(opts.totalAngleDegrees ?? 270) || 270) * Math.PI) / 180;
607
+ const dAngle = totalAngleRad / steps;
608
+ const totalH = steps * stepRise;
609
+ // Central column
610
+ const centerPole = MeshBuilder.CreateCylinder(`${name}_center_pole`, { height: totalH + railingHeight, diameter: innerR * 2, tessellation: 20 }, scene);
611
+ centerPole.position.set(0, (totalH + railingHeight) * 0.5, 0);
612
+ centerPole.bakeCurrentTransformIntoVertices();
613
+ parts.push(centerPole);
614
+ const railPath = [];
615
+ for (let i = 0; i < steps; i++) {
616
+ const a = (i + 0.5) * dAngle;
617
+ const yTop = (i + 1) * stepRise;
618
+ const midR = (innerR + outerR) * 0.5;
619
+ const arcChord = Math.max(0.12, midR * Math.abs(dAngle) + nosing);
620
+ const treadH = Math.min(0.06, stepRise * 0.4);
621
+ const tread = createRoundedBoxMesh(`${name}_spiral_tread_${i}`, { width: outerR - innerR, height: treadH, depth: arcChord, radius: 0.01, segments: 2 }, scene);
622
+ tread.rotation.y = -a;
623
+ tread.position.set(Math.cos(a) * midR, yTop - treadH * 0.5, Math.sin(a) * midR);
624
+ tread.bakeCurrentTransformIntoVertices();
625
+ parts.push(tread);
626
+ if (railingOpt !== 'none') {
627
+ const rx = Math.cos(a) * (outerR - 0.05);
628
+ const rz = Math.sin(a) * (outerR - 0.05);
629
+ const post = MeshBuilder.CreateCylinder(`${name}_spiral_post_${i}`, { height: railingHeight, diameter: 0.035, tessellation: 10 }, scene);
630
+ post.position.set(rx, yTop + railingHeight * 0.5, rz);
631
+ post.bakeCurrentTransformIntoVertices();
632
+ parts.push(post);
633
+ railPath.push(new Vector3(rx, yTop + railingHeight, rz));
634
+ }
635
+ }
636
+ if (railPath.length >= 2) {
637
+ const handrail = MeshBuilder.CreateTube(`${name}_spiral_rail`, { path: railPath, radius: 0.028, tessellation: 12 }, scene);
638
+ parts.push(handrail);
639
+ }
640
+ return makeUpdatableMerged(parts, name, scene);
641
+ }
642
+ // Straight staircase along +Z (from z = 0 to z = steps * stepRun, y = 0 to y = steps * stepRise)
643
+ const treadThickness = Math.min(0.055, stepRise * 0.35);
644
+ const includeSolidSteps = opts.stringers !== false;
645
+ for (let i = 0; i < steps; i++) {
646
+ const yTop = (i + 1) * stepRise;
647
+ const zCenter = (i + 0.5) * stepRun;
648
+ // Beveled tread with front nosing overhang
649
+ const tread = createRoundedBoxMesh(`${name}_tread_${i}`, {
650
+ width: width + nosing,
651
+ height: treadThickness,
652
+ depth: stepRun + nosing,
653
+ radius: Math.min(0.012, treadThickness * 0.35),
654
+ segments: 2,
655
+ }, scene);
656
+ tread.position.set(0, yTop - treadThickness * 0.5, zCenter - nosing * 0.5);
657
+ tread.bakeCurrentTransformIntoVertices();
658
+ parts.push(tread);
659
+ // Riser / step body
660
+ if (includeSolidSteps) {
661
+ const bodyH = yTop - treadThickness;
662
+ if (bodyH > 0.01) {
663
+ const riserBox = MeshBuilder.CreateBox(`${name}_riser_${i}`, { width, height: bodyH, depth: stepRun }, scene);
664
+ riserBox.position.set(0, bodyH * 0.5, zCenter);
665
+ riserBox.bakeCurrentTransformIntoVertices();
666
+ parts.push(riserBox);
667
+ }
668
+ }
669
+ }
670
+ // Optional Railings (left: -X, right: +X, or both)
671
+ const sides = [];
672
+ if (railingOpt === 'left' || railingOpt === 'both')
673
+ sides.push(-1);
674
+ if (railingOpt === 'right' || railingOpt === 'both')
675
+ sides.push(1);
676
+ for (const side of sides) {
677
+ const rx = side * (width * 0.5 - 0.04);
678
+ const railPts = [];
679
+ for (let i = 0; i < steps; i++) {
680
+ const yTop = (i + 1) * stepRise;
681
+ const rz = (i + 0.5) * stepRun;
682
+ const isEndPost = i === 0 || i === steps - 1;
683
+ const post = MeshBuilder.CreateCylinder(`${name}_post_${side}_${i}`, {
684
+ height: railingHeight,
685
+ diameter: isEndPost ? 0.065 : 0.032,
686
+ tessellation: 10,
687
+ }, scene);
688
+ post.position.set(rx, yTop + railingHeight * 0.5, rz);
689
+ post.bakeCurrentTransformIntoVertices();
690
+ parts.push(post);
691
+ railPts.push(new Vector3(rx, yTop + railingHeight, rz));
692
+ }
693
+ if (railPts.length >= 2) {
694
+ const rail = MeshBuilder.CreateTube(`${name}_handrail_${side}`, { path: railPts, radius: 0.028, tessellation: 12, cap: Mesh.CAP_ALL }, scene);
695
+ parts.push(rail);
696
+ }
697
+ }
698
+ return makeUpdatableMerged(parts, name, scene);
699
+ }
700
+ /**
701
+ * Builds a parametric architectural roof standing on Y = 0 with eaves overhang,
702
+ * real fascia slab thickness, ridge cap, and gable end walls.
703
+ */
704
+ export function buildRoofMesh(scene, name, opts = {}) {
705
+ const style = (opts.style || 'gable').toLowerCase();
706
+ const width = Math.max(0.4, Number(opts.width ?? 4.0));
707
+ const depth = Math.max(0.4, Number(opts.depth ?? 4.0));
708
+ const overhang = Math.max(0, Number(opts.overhang ?? 0.25));
709
+ const thickness = Math.max(0.04, Number(opts.thickness ?? 0.14));
710
+ const pitchRad = opts.pitchDegrees
711
+ ? (Math.max(5, Math.min(75, Number(opts.pitchDegrees))) * Math.PI) / 180
712
+ : Math.atan2(1.4, width * 0.5);
713
+ const height = opts.height !== undefined
714
+ ? Math.max(0.15, Number(opts.height))
715
+ : Math.max(0.2, width * 0.5 * Math.tan(pitchRad));
716
+ const totalW = width + overhang * 2;
717
+ const totalD = depth + overhang * 2;
718
+ const hw = totalW * 0.5;
719
+ const hd = totalD * 0.5;
720
+ const parts = [];
721
+ if (style === 'dome') {
722
+ const dome = MeshBuilder.CreateSphere(`${name}_dome`, {
723
+ diameterX: totalW,
724
+ diameterY: height * 2,
725
+ diameterZ: totalD,
726
+ slice: 0.5,
727
+ segments: 24,
728
+ sideOrientation: Mesh.DOUBLESIDE,
729
+ }, scene);
730
+ const vd = VertexData.ExtractFromMesh(dome);
731
+ vd.applyToMesh(dome, true);
732
+ return dome;
733
+ }
734
+ if (style === 'pyramid' || style === 'hip') {
735
+ const ridgeHalfLen = style === 'pyramid' ? 0 : Math.max(0, hd - hw);
736
+ const positions = [
737
+ // Bottom perimeter (0..3)
738
+ -hw, 0, -hd,
739
+ hw, 0, -hd,
740
+ hw, 0, hd,
741
+ -hw, 0, hd,
742
+ // Ridge endpoints (4, 5)
743
+ 0, height, -ridgeHalfLen,
744
+ 0, height, ridgeHalfLen,
745
+ ];
746
+ const indices = [
747
+ // Bottom quad
748
+ 0, 1, 2, 0, 2, 3,
749
+ // Front slope (-Z)
750
+ 0, 4, 1,
751
+ // Back slope (+Z)
752
+ 2, 5, 3,
753
+ // Right slope (+X)
754
+ 1, 4, 5, 1, 5, 2,
755
+ // Left slope (-X)
756
+ 3, 5, 4, 3, 4, 0,
757
+ ];
758
+ // Convert to flat-shaded crisp architectural faces by unsharing vertices per triangle
759
+ const flatPos = [];
760
+ const flatIdx = [];
761
+ const flatUV = [];
762
+ for (let i = 0; i < indices.length; i += 3) {
763
+ const a = indices[i] * 3;
764
+ const b = indices[i + 1] * 3;
765
+ const c = indices[i + 2] * 3;
766
+ const baseV = flatPos.length / 3;
767
+ flatPos.push(positions[a], positions[a + 1], positions[a + 2], positions[b], positions[b + 1], positions[b + 2], positions[c], positions[c + 1], positions[c + 2]);
768
+ flatUV.push(0, 0, 1, 0, 0.5, 1);
769
+ flatIdx.push(baseV, baseV + 1, baseV + 2);
770
+ }
771
+ const hipMesh = new Mesh(`${name}_hip`, scene);
772
+ const vd = new VertexData();
773
+ const normals = new Float32Array(flatPos.length);
774
+ VertexData.ComputeNormals(flatPos, flatIdx, normals);
775
+ vd.positions = flatPos;
776
+ vd.indices = flatIdx;
777
+ vd.normals = normals;
778
+ vd.uvs = flatUV;
779
+ vd.applyToMesh(hipMesh, true);
780
+ parts.push(hipMesh);
781
+ // Fascia eave trim band around base
782
+ const fascia = createRoundedBoxMesh(`${name}_fascia`, { width: totalW, height: thickness, depth: totalD, radius: 0.01, segments: 1 }, scene);
783
+ fascia.position.set(0, thickness * 0.5, 0);
784
+ fascia.bakeCurrentTransformIntoVertices();
785
+ parts.push(fascia);
786
+ return makeUpdatableMerged(parts, name, scene);
787
+ }
788
+ if (style === 'shed') {
789
+ const slopeLen = Math.hypot(totalW, height);
790
+ const angle = Math.atan2(height, totalW);
791
+ const slab = createRoundedBoxMesh(`${name}_shed_slab`, { width: slopeLen, height: thickness, depth: totalD, radius: 0.012, segments: 2 }, scene);
792
+ slab.rotation.z = angle;
793
+ slab.position.set(0, height * 0.5 + thickness * 0.5, 0);
794
+ slab.bakeCurrentTransformIntoVertices();
795
+ parts.push(slab);
796
+ return makeUpdatableMerged(parts, name, scene);
797
+ }
798
+ // Gable, Gambrel, or Mansard roof
799
+ const slopeRun = hw;
800
+ const slopeLen = Math.hypot(slopeRun, height);
801
+ const slopeAngle = Math.atan2(height, slopeRun);
802
+ for (const side of [-1, 1]) {
803
+ const slab = createRoundedBoxMesh(`${name}_slope_${side}`, { width: slopeLen + thickness * 0.5, height: thickness, depth: totalD, radius: 0.012, segments: 2 }, scene);
804
+ slab.rotation.z = -side * slopeAngle;
805
+ slab.position.set(side * (slopeRun * 0.5), height * 0.5 + thickness * 0.4, 0);
806
+ slab.bakeCurrentTransformIntoVertices();
807
+ parts.push(slab);
808
+ }
809
+ // Optional Ridge Cap beam along the peak
810
+ if (opts.ridgeCap !== false) {
811
+ const ridge = createRoundedBoxMesh(`${name}_ridge_cap`, { width: thickness * 1.6, height: thickness * 1.2, depth: totalD + 0.04, radius: 0.015, segments: 2 }, scene);
812
+ ridge.position.set(0, height + thickness * 0.45, 0);
813
+ ridge.bakeCurrentTransformIntoVertices();
814
+ parts.push(ridge);
815
+ }
816
+ // Optional Gable Triangular End Walls (inward of overhang)
817
+ if (opts.gableWall !== false) {
818
+ const gw = width * 0.5;
819
+ const gableShape = [
820
+ new Vector3(-gw, 0, 0),
821
+ new Vector3(gw, 0, 0),
822
+ new Vector3(0, 0, height),
823
+ ];
824
+ const gableMesh = MeshBuilder.ExtrudePolygon(`${name}_gable_core`, { shape: gableShape, depth, sideOrientation: Mesh.DOUBLESIDE, updatable: true }, scene, earcut);
825
+ gableMesh.rotation.x = -Math.PI / 2;
826
+ gableMesh.position.set(0, 0, -depth * 0.5);
827
+ gableMesh.bakeCurrentTransformIntoVertices();
828
+ parts.push(gableMesh);
829
+ }
830
+ return makeUpdatableMerged(parts, name, scene);
831
+ }
832
+ //# sourceMappingURL=architecture.js.map