@divinevoxel/vlox 0.0.76 → 0.0.77

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 (315) hide show
  1. package/Builder/Tools/Brush/BrushTool.d.ts +16 -9
  2. package/Builder/Tools/Brush/BrushTool.js +258 -52
  3. package/Builder/Tools/BuilderToolBase.d.ts +36 -0
  4. package/Builder/Tools/BuilderToolBase.js +39 -0
  5. package/Builder/Tools/Hand/HandTool.d.ts +9 -7
  6. package/Builder/Tools/Hand/HandTool.js +40 -23
  7. package/Builder/Tools/Path/PahtTool.d.ts +12 -7
  8. package/Builder/Tools/Path/PahtTool.js +32 -21
  9. package/Builder/Tools/Sculpt/SculptTool.d.ts +34 -0
  10. package/Builder/Tools/Sculpt/SculptTool.js +102 -0
  11. package/Builder/Tools/Shape/ShapeTool.d.ts +32 -0
  12. package/Builder/Tools/Shape/ShapeTool.js +78 -0
  13. package/Builder/Tools/Template/TemplateTool.d.ts +35 -0
  14. package/Builder/Tools/Template/TemplateTool.js +73 -0
  15. package/Builder/Tools/Wand/WandTool.d.ts +9 -7
  16. package/Builder/Tools/Wand/WandTool.js +43 -20
  17. package/Builder/Tools/Wrench/WrenchTool.d.ts +7 -7
  18. package/Builder/Tools/Wrench/WrenchTool.js +22 -13
  19. package/Builder/Util/FreeBoxSelection.d.ts +12 -0
  20. package/Builder/Util/FreeBoxSelection.js +21 -0
  21. package/Builder/Util/FreePointSelection.d.ts +14 -0
  22. package/Builder/Util/FreePointSelection.js +39 -0
  23. package/Builder/Util/SurfaceBoxSelection.d.ts +12 -0
  24. package/Builder/{Tools/Box/BoxSelection.js → Util/SurfaceBoxSelection.js} +1 -3
  25. package/Builder/VoxelBuildSpace.d.ts +37 -25
  26. package/Builder/VoxelBuildSpace.js +99 -40
  27. package/Builder/World/InitTasks.js +17 -22
  28. package/Mesher/Geomtry/Proto/ProtoMesh.d.ts +18 -0
  29. package/Mesher/Geomtry/Proto/ProtoMesh.js +73 -0
  30. package/Mesher/Geomtry/{VoxelMeshBuffers.d.ts → Proto/ProtoMeshBuffer.d.ts} +2 -2
  31. package/Mesher/Geomtry/{VoxelMeshBuffers.js → Proto/ProtoMeshBuffer.js} +2 -2
  32. package/Mesher/Geomtry/Shapes/Box.d.ts +2 -9
  33. package/Mesher/Geomtry/Shapes/Box.js +7 -12
  34. package/Mesher/Geomtry/Transform/TransformBox.js +5 -2
  35. package/Mesher/InitMesher.js +4 -4
  36. package/Mesher/InitTask.js +2 -2
  37. package/Mesher/Items/Base/CompactItemMesh.d.ts +3 -0
  38. package/Mesher/Items/Base/CompactItemMesh.js +20 -0
  39. package/Mesher/Items/Geomtry/ItemGeometryBuilder.d.ts +5 -0
  40. package/Mesher/Items/Geomtry/ItemGeometryBuilder.js +131 -0
  41. package/Mesher/Items/Geomtry/ItemMeshVertexStructCursor.d.ts +48 -0
  42. package/Mesher/Items/Geomtry/ItemMeshVertexStructCursor.js +114 -0
  43. package/Mesher/Items/MeshTexture.d.ts +1 -0
  44. package/Mesher/Items/MeshTexture.js +214 -0
  45. package/Mesher/Items/MeshTextureO.js +277 -0
  46. package/Mesher/Items/Models/ItemModelBuilder.d.ts +27 -0
  47. package/Mesher/Items/Models/ItemModelBuilder.js +64 -0
  48. package/Mesher/Types/ItemMesh.types.d.ts +5 -0
  49. package/Mesher/Types/ItemMesh.types.js +12 -0
  50. package/Mesher/Types/Mesher.types.d.ts +15 -9
  51. package/Mesher/Types/Mesher.types.js +14 -0
  52. package/Mesher/Types/VoxelMesh.types.js +7 -6
  53. package/Mesher/Voxels/Base/CompactTemplateMesh.d.ts +3 -0
  54. package/Mesher/{Functions/CompactVoxelMesh.js → Voxels/Base/CompactTemplateMesh.js} +4 -40
  55. package/Mesher/{Functions → Voxels/Base}/CompactVoxelSectionMesh.d.ts +2 -2
  56. package/Mesher/{Functions → Voxels}/Base/MeshSectionBase.d.ts +1 -1
  57. package/Mesher/{Functions → Voxels}/Base/MeshSectionBase.js +9 -8
  58. package/Mesher/{Geomtry → Voxels/Geomtry}/CompactedSectionVoxelMesh.d.ts +1 -1
  59. package/Mesher/{Geomtry → Voxels/Geomtry}/CompactedSectionVoxelMesh.js +1 -1
  60. package/Mesher/{Geomtry → Voxels/Geomtry}/VoxelGeometryBuilder.d.ts +2 -2
  61. package/Mesher/{Geomtry → Voxels/Geomtry}/VoxelGeometryBuilder.js +1 -1
  62. package/Mesher/{Geomtry → Voxels/Geomtry}/VoxelMeshBVHBuilder.d.ts +1 -1
  63. package/Mesher/{Geomtry → Voxels/Geomtry}/VoxelMeshBVHBuilder.js +2 -2
  64. package/Mesher/Voxels/MeshTemplate.d.ts +3 -0
  65. package/Mesher/Voxels/MeshTemplate.js +81 -0
  66. package/Mesher/{Functions → Voxels}/MeshVoxel.d.ts +1 -1
  67. package/Mesher/{Functions → Voxels}/MeshVoxel.js +4 -4
  68. package/Mesher/{Models → Voxels/Models}/Common/Calc/CalcConstants.d.ts +2 -2
  69. package/Mesher/{Models → Voxels/Models}/Common/Calc/CalcConstants.js +4 -4
  70. package/Mesher/{Models → Voxels/Models}/Common/Calc/FaceDataCalc.d.ts +1 -1
  71. package/Mesher/{Models → Voxels/Models}/Common/Calc/FaceDataCalc.js +2 -2
  72. package/Mesher/{Models → Voxels/Models}/Common/Faces/CullRulledFace.js +1 -1
  73. package/Mesher/{Models → Voxels/Models}/Common/Faces/ShadeRulelessFace.d.ts +1 -1
  74. package/Mesher/{Models → Voxels/Models}/Common/Faces/ShadeRulledFace.d.ts +1 -1
  75. package/Mesher/{Models → Voxels/Models}/Common/Faces/ShadeRulledFace.js +1 -1
  76. package/Mesher/{Models → Voxels/Models}/Common/GetTexture.d.ts +3 -3
  77. package/Mesher/{Models → Voxels/Models}/Nodes/Custom/Liquid/FlowGradient.d.ts +1 -1
  78. package/Mesher/{Models → Voxels/Models}/Nodes/Custom/Liquid/FlowGradient.js +1 -1
  79. package/Mesher/{Models → Voxels/Models}/Nodes/Custom/Liquid/LiquidGeomtryNode.d.ts +3 -3
  80. package/Mesher/{Models → Voxels/Models}/Nodes/Custom/Liquid/LiquidGeomtryNode.js +14 -16
  81. package/Mesher/{Models → Voxels/Models}/Nodes/Default/QuadVoxelGeometryNode.d.ts +2 -2
  82. package/Mesher/{Models → Voxels/Models}/Nodes/Default/QuadVoxelGeometryNode.js +1 -1
  83. package/Mesher/{Models → Voxels/Models}/Nodes/Default/TriangleVoxelGeometryNode.d.ts +2 -2
  84. package/Mesher/{Models → Voxels/Models}/Nodes/Default/TriangleVoxelGeometryNode.js +1 -1
  85. package/Mesher/{Models → Voxels/Models}/Nodes/Types/QuadVoxelGometryNodeTypes.d.ts +2 -2
  86. package/Mesher/{Models → Voxels/Models}/Nodes/Types/TriangleVoxelGometryNodeTypes.d.ts +1 -1
  87. package/Mesher/{Models → Voxels/Models}/Nodes/VoxelGeometryConstructor.d.ts +2 -2
  88. package/Mesher/Voxels/Models/Procedures/Default/ConsistentRotationTextureProcedure.d.ts +24 -0
  89. package/Mesher/{Models → Voxels/Models}/Procedures/Default/ConsistentRotationTextureProcedure.js +2 -2
  90. package/Mesher/{Models → Voxels/Models}/Procedures/Default/OutlinedTextureProcedure.d.ts +4 -5
  91. package/Mesher/Voxels/Models/Procedures/Default/OutlinedTextureProcedure.js +205 -0
  92. package/Mesher/Voxels/Models/Procedures/Default/PillarTextureProcedure.d.ts +28 -0
  93. package/Mesher/Voxels/Models/Procedures/Default/PillarTextureProcedure.js +109 -0
  94. package/Mesher/{Models → Voxels/Models}/Procedures/TextureProcedure.d.ts +3 -3
  95. package/Mesher/{Models → Voxels/Models}/Procedures/TextureProcedureRegister.js +2 -0
  96. package/Mesher/{Models → Voxels/Models}/VoxelConstructor.d.ts +4 -4
  97. package/Mesher/{Models → Voxels/Models}/VoxelConstructor.js +3 -3
  98. package/Mesher/{Models → Voxels/Models}/VoxelGeometryBuilderCacheSpace.d.ts +2 -2
  99. package/Mesher/{Models → Voxels/Models}/VoxelGeometryBuilderCacheSpace.js +2 -2
  100. package/Mesher/{Models → Voxels/Models}/VoxelModelBuilder.d.ts +7 -7
  101. package/Mesher/{Models → Voxels/Models}/VoxelModelBuilder.js +6 -5
  102. package/Mesher/{Models → Voxels/Models}/VoxelModelConstructorRegister.d.ts +4 -4
  103. package/Mesher/{Models → Voxels/Models}/VoxelModelConstructorRegister.js +2 -2
  104. package/Mesher/{Models → Voxels/Models}/VoxelModelEffect.d.ts +1 -1
  105. package/Mesher/{Models → Voxels/Models}/VoxelModelEffect.js +1 -1
  106. package/Renderer/Classes/DVESectionMeshes.d.ts +1 -1
  107. package/Renderer/MeshManager.js +1 -1
  108. package/Settings/EngineSettings.types.d.ts +2 -1
  109. package/Settings/EngineSettings.types.js +3 -1
  110. package/Tasks/Paint/Common.js +14 -9
  111. package/Tasks/Paint/Erase/EraseVoxelSelection.d.ts +4 -0
  112. package/Tasks/Paint/Erase/EraseVoxelSelection.js +33 -0
  113. package/Tasks/Paint/Erase/EraseVoxelTemplate.js +1 -2
  114. package/Tasks/Paint/Paint/PaintVoxel.js +1 -1
  115. package/Tasks/Paint/Paint/PaintVoxelTemplate.js +1 -1
  116. package/Tasks/Propagation/Illumanation/RGBUpdate.js +1 -1
  117. package/Tasks/Tasks.types.d.ts +2 -0
  118. package/Tasks/TasksIds.d.ts +1 -0
  119. package/Tasks/TasksIds.js +1 -0
  120. package/Tasks/WorldGeneration/InitTasks.js +3 -1
  121. package/Templates/Archive/ArchivedVoxelTemplate.d.ts +5 -5
  122. package/Templates/Archive/ArchivedVoxelTemplate.js +52 -49
  123. package/Templates/Archive/Functions/CreateArchivedTemplate.js +0 -2
  124. package/Templates/Archive/Functions/ExportArchiedTemplateJSON.js +0 -1
  125. package/Templates/Archive/Functions/ImportArchivedTemplateJSON.js +0 -2
  126. package/Templates/Cursor/TemplateCursor.d.ts +6 -1
  127. package/Templates/Cursor/TemplateCursor.js +13 -2
  128. package/Templates/Cursor/TemplateProxy.js +1 -6
  129. package/Templates/Cursor/TemplateVoxelCursor.d.ts +1 -0
  130. package/Templates/Cursor/TemplateVoxelCursor.js +6 -0
  131. package/Templates/Full/FullVoxelTemplate.d.ts +4 -4
  132. package/Templates/Full/FullVoxelTemplate.js +29 -18
  133. package/Templates/Functions/ExtrudeSelection.d.ts +5 -0
  134. package/Templates/Functions/ExtrudeSelection.js +44 -0
  135. package/Templates/Functions/FillSelection.d.ts +4 -0
  136. package/Templates/Functions/FillSelection.js +20 -0
  137. package/Templates/Functions/FlipTemplate.d.ts +2 -2
  138. package/Templates/Functions/FlipTemplate.js +8 -8
  139. package/Templates/Functions/RotateTemplate.d.ts +2 -2
  140. package/Templates/Path/VoxelPath.js +2 -1
  141. package/Templates/Selection/VoxelBFSSelection.d.ts +3 -6
  142. package/Templates/Selection/VoxelBFSSelection.js +20 -24
  143. package/Templates/Selection/{VoxelBoxSelection.d.ts → VoxelBoundsSelection.d.ts} +9 -6
  144. package/Templates/Selection/{VoxelBoxSelection.js → VoxelBoundsSelection.js} +29 -22
  145. package/Templates/Selection/VoxelPointSelection.d.ts +8 -6
  146. package/Templates/Selection/VoxelPointSelection.js +25 -24
  147. package/Templates/Selection/VoxelSelection.d.ts +18 -0
  148. package/Templates/Selection/VoxelSurfaceSelection.d.ts +5 -12
  149. package/Templates/Selection/VoxelSurfaceSelection.js +76 -90
  150. package/Templates/Selection/VoxelTemplateSelection.d.ts +10 -4
  151. package/Templates/Selection/VoxelTemplateSelection.js +18 -10
  152. package/Templates/Shapes/Selections/BoxVoxelShapeSelection.d.ts +28 -0
  153. package/Templates/Shapes/Selections/BoxVoxelShapeSelection.js +77 -0
  154. package/Templates/Shapes/Selections/ConeVoxelShapeSelection.d.ts +28 -0
  155. package/Templates/Shapes/Selections/ConeVoxelShapeSelection.js +77 -0
  156. package/Templates/Shapes/Selections/CylinderVoxelShapeSelection.d.ts +28 -0
  157. package/Templates/Shapes/Selections/CylinderVoxelShapeSelection.js +77 -0
  158. package/Templates/Shapes/Selections/EllipsoidVoxelShapeSelection.d.ts +28 -0
  159. package/Templates/Shapes/Selections/EllipsoidVoxelShapeSelection.js +92 -0
  160. package/Templates/Shapes/Selections/OctahedronVoxelShapeSelection.d.ts +28 -0
  161. package/Templates/Shapes/Selections/OctahedronVoxelShapeSelection.js +76 -0
  162. package/Templates/Shapes/Selections/PyramidVoxelShapeSelection.d.ts +37 -0
  163. package/Templates/Shapes/Selections/PyramidVoxelShapeSelection.js +137 -0
  164. package/Templates/Shapes/Selections/SphereVoxelShapeSelection.d.ts +20 -0
  165. package/Templates/Shapes/Selections/SphereVoxelShapeSelection.js +61 -0
  166. package/Templates/Shapes/Selections/TorusVoxelShapeSelection.d.ts +28 -0
  167. package/Templates/Shapes/Selections/TorusVoxelShapeSelection.js +76 -0
  168. package/Templates/Shapes/Selections/VoxelShapeSelection.d.ts +5 -0
  169. package/Templates/Shapes/Selections/VoxelShapeSelection.js +1 -0
  170. package/Templates/Shapes/VoxelShape.types.d.ts +2 -0
  171. package/Templates/Shapes/VoxelShape.types.js +8 -0
  172. package/Templates/Shapes/VoxelShapeTemplate.d.ts +37 -0
  173. package/Templates/Shapes/{BasicVoxelShapeTemplate.js → VoxelShapeTemplate.js} +43 -37
  174. package/Templates/Shapes/VoxelShapeTemplate.types.d.ts +4 -13
  175. package/Templates/Shapes/VoxelShapeTemplate.types.js +0 -1
  176. package/Templates/{VoxelTempateRegister.d.ts → VoxelTemplateRegister.d.ts} +4 -0
  177. package/Templates/VoxelTemplateRegister.js +60 -0
  178. package/Templates/VoxelTemplates.types.d.ts +2 -3
  179. package/Textures/Classes/CompiledTexture.d.ts +2 -0
  180. package/Textures/Classes/CompiledTexture.js +19 -1
  181. package/Textures/Functions/BuildTextureData.js +13 -0
  182. package/Textures/TextureManager.d.ts +1 -0
  183. package/Textures/TextureManager.js +11 -5
  184. package/Tools/Brush/Brush.d.ts +2 -0
  185. package/Tools/Brush/Brush.js +19 -0
  186. package/Tools/Tasks/TasksTool.d.ts +2 -1
  187. package/Tools/Tasks/TasksTool.js +2 -0
  188. package/Voxels/Cursor/DataCursor.interface.d.ts +4 -0
  189. package/Voxels/Cursor/VoxelLightData.js +2 -2
  190. package/Voxels/Functions/BuildTagData.js +1 -1
  191. package/Voxels/Indexes/VoxelIndex.d.ts +1 -0
  192. package/Voxels/Indexes/VoxelIndex.js +11 -13
  193. package/Voxels/InitVoxelData.js +5 -14
  194. package/Voxels/Interaction/Functions/PickVoxel.d.ts +0 -5
  195. package/Voxels/Interaction/Functions/PickVoxel.js +64 -85
  196. package/Voxels/Interaction/Functions/PickVoxelWorld.js +6 -3
  197. package/Voxels/Models/CompiledVoxelModel.types.d.ts +1 -1
  198. package/Voxels/Models/Defaults/CubeVoxelGeometry.js +11 -0
  199. package/Voxels/Models/Defaults/CubeVoxelModels.js +44 -99
  200. package/Voxels/Models/Defaults/PanelVoxelGeometry.d.ts +1 -3
  201. package/Voxels/Models/Defaults/PanelVoxelGeometry.js +2 -226
  202. package/Voxels/Models/Defaults/PanelVoxelModels.d.ts +1 -0
  203. package/Voxels/Models/Defaults/PanelVoxelModels.js +100 -258
  204. package/Voxels/Models/Defaults/StairVoxelModel.js +2 -2
  205. package/Voxels/Models/Rules/Classes/GeomtryInput.d.ts +4 -1
  206. package/Voxels/Models/Rules/Classes/GeomtryInput.js +26 -5
  207. package/Voxels/Models/Rules/Classes/VoxelRulesGeometry.d.ts +1 -1
  208. package/Voxels/Models/Rules/Functions/BuildFinalInputs.js +23 -8
  209. package/Voxels/Models/Rules/Functions/Compile/CompileGeomtryNodes.d.ts +1 -1
  210. package/Voxels/Models/Rules/Functions/Compile/Nodes/CompileBoxGeometryNode.d.ts +1 -1
  211. package/Voxels/Models/Rules/Functions/Compile/Nodes/CompileQuadGeometryNode.d.ts +1 -1
  212. package/Voxels/Models/Rules/Functions/Compile/Nodes/CompileQuadGeometryNode.js +1 -1
  213. package/Voxels/Models/Rules/Functions/Compile/Nodes/CompileTriangleGeometryNode.d.ts +1 -1
  214. package/Voxels/Models/Rules/Functions/Compile/Nodes/CompileTriangleGeometryNode.js +1 -1
  215. package/Voxels/Models/VoxelModel.types.d.ts +6 -1
  216. package/Voxels/Types/PaintVoxelData.d.ts +2 -0
  217. package/Voxels/Types/PaintVoxelData.js +51 -0
  218. package/World/Cursor/SectionCursor.d.ts +4 -0
  219. package/World/Cursor/SectionCursor.js +13 -16
  220. package/World/Cursor/SectorCursor.d.ts +4 -0
  221. package/World/Cursor/SectorCursor.js +13 -16
  222. package/World/Cursor/WorldCursor.d.ts +4 -0
  223. package/World/Cursor/WorldCursor.js +8 -0
  224. package/World/Sector/SectorHeightMap.d.ts +6 -0
  225. package/World/Sector/SectorHeightMap.js +6 -0
  226. package/World/SnapShot/SectionSnapShotCursor.d.ts +3 -0
  227. package/World/SnapShot/SectionSnapShotCursor.js +6 -0
  228. package/World/WorldSpaces.js +3 -3
  229. package/WorldSimulation/Dimensions/DimensionSimulation.d.ts +5 -1
  230. package/WorldSimulation/Dimensions/DimensionSimulation.js +12 -0
  231. package/WorldSimulation/Dimensions/Generator.d.ts +1 -0
  232. package/WorldSimulation/Dimensions/Generator.js +1 -0
  233. package/WorldSimulation/Dimensions/SimulationSector.d.ts +3 -0
  234. package/WorldSimulation/Dimensions/SimulationSector.js +71 -41
  235. package/WorldSimulation/Internal/WorldSimulationTasks.js +5 -2
  236. package/WorldSimulation/Procedures/BuildOnly.d.ts +10 -0
  237. package/WorldSimulation/Procedures/BuildOnly.js +55 -0
  238. package/WorldSimulation/Procedures/InitalLoad.js +3 -0
  239. package/WorldSimulation/Tasks/SimulationTaskBase.d.ts +2 -0
  240. package/WorldSimulation/Tasks/SimulationTaskBase.js +11 -3
  241. package/WorldSimulation/Tasks/TaskSegment.d.ts +2 -1
  242. package/WorldSimulation/Tasks/TaskSegment.js +3 -1
  243. package/WorldSimulation/Tick/TickQueue.d.ts +2 -0
  244. package/WorldSimulation/Tick/TickQueue.js +26 -0
  245. package/WorldSimulation/Tools/SimulationBrush.d.ts +3 -0
  246. package/WorldSimulation/Tools/SimulationBrush.js +52 -0
  247. package/WorldSimulation/Voxels/Behaviors/Types/DefaultVoxelBehavior.js +3 -0
  248. package/WorldSimulation/Voxels/Behaviors/Types/LiquidVoxelBehavior.js +21 -1
  249. package/WorldSimulation/Voxels/Behaviors/VoxelBehaviors.d.ts +2 -0
  250. package/WorldSimulation/Voxels/Behaviors/VoxelBehaviors.js +6 -0
  251. package/WorldSimulation/Voxels/Ticks/Types/LiquidVoxelUpdate.js +39 -14
  252. package/WorldSimulation/WorldSimulation.d.ts +10 -0
  253. package/WorldSimulation/WorldSimulation.js +41 -1
  254. package/package.json +1 -30
  255. package/Builder/Tools/Box/BoxSelection.d.ts +0 -12
  256. package/Builder/Tools/Box/BoxTool.d.ts +0 -31
  257. package/Builder/Tools/Box/BoxTool.js +0 -91
  258. package/Builder/Tools/Box/BoxToolTemplate.d.ts +0 -13
  259. package/Builder/Tools/Box/BoxToolTemplate.js +0 -23
  260. package/Builder/VoxelBuilder.types.d.ts +0 -0
  261. package/Builder/VoxelBuilder.types.js +0 -1
  262. package/Mesher/Functions/CompactVoxelMesh.d.ts +0 -3
  263. package/Mesher/Functions/MeshTexture.js +0 -278
  264. package/Mesher/Geomtry/VoxelMesh.d.ts +0 -12
  265. package/Mesher/Geomtry/VoxelMesh.js +0 -25
  266. package/Mesher/Models/Procedures/Default/ConsistentRotationTextureProcedure.d.ts +0 -25
  267. package/Mesher/Models/Procedures/Default/OutlinedTextureProcedure.js +0 -162
  268. package/Templates/Selection/VoxelSelecton.d.ts +0 -9
  269. package/Templates/Shapes/BasicVoxelShapeTemplate.d.ts +0 -36
  270. package/Templates/Shapes/BoxVoxelTemplate.d.ts +0 -23
  271. package/Templates/Shapes/BoxVoxelTemplate.js +0 -83
  272. package/Templates/Shapes/ConeVoxelTemplate.d.ts +0 -23
  273. package/Templates/Shapes/ConeVoxelTemplate.js +0 -73
  274. package/Templates/Shapes/CylinderVoxelTemplate.d.ts +0 -23
  275. package/Templates/Shapes/CylinderVoxelTemplate.js +0 -73
  276. package/Templates/Shapes/EllipsoidVoxelTemplate.d.ts +0 -23
  277. package/Templates/Shapes/EllipsoidVoxelTemplate.js +0 -89
  278. package/Templates/Shapes/OctahedronVoxelTemplate.d.ts +0 -23
  279. package/Templates/Shapes/OctahedronVoxelTemplate.js +0 -73
  280. package/Templates/Shapes/PyramidVoxelTemplate.d.ts +0 -31
  281. package/Templates/Shapes/PyramidVoxelTemplate.js +0 -148
  282. package/Templates/Shapes/SphereVoxelTemplate.d.ts +0 -15
  283. package/Templates/Shapes/SphereVoxelTemplate.js +0 -59
  284. package/Templates/Shapes/TorusVoxelTemplate.d.ts +0 -23
  285. package/Templates/Shapes/TorusVoxelTemplate.js +0 -73
  286. package/Templates/VoxelTempateRegister.js +0 -30
  287. /package/Mesher/{Functions/MeshTexture.d.ts → Items/MeshTextureO.d.ts} +0 -0
  288. /package/Mesher/{Functions → Voxels/Base}/CompactVoxelSectionMesh.js +0 -0
  289. /package/Mesher/{Geomtry → Voxels/Geomtry}/VoxelMeshBVHStructCursor.d.ts +0 -0
  290. /package/Mesher/{Geomtry → Voxels/Geomtry}/VoxelMeshBVHStructCursor.js +0 -0
  291. /package/Mesher/{Geomtry → Voxels/Geomtry}/VoxelMeshVertexStructCursor.d.ts +0 -0
  292. /package/Mesher/{Geomtry → Voxels/Geomtry}/VoxelMeshVertexStructCursor.js +0 -0
  293. /package/Mesher/{Geomtry → Voxels/Geomtry}/VoxelShaderData.d.ts +0 -0
  294. /package/Mesher/{Geomtry → Voxels/Geomtry}/VoxelShaderData.js +0 -0
  295. /package/Mesher/{Functions → Voxels}/MeshSection.d.ts +0 -0
  296. /package/Mesher/{Functions → Voxels}/MeshSection.js +0 -0
  297. /package/Mesher/{Functions → Voxels}/MeshSectionSnapShot.d.ts +0 -0
  298. /package/Mesher/{Functions → Voxels}/MeshSectionSnapShot.js +0 -0
  299. /package/Mesher/{Models → Voxels/Models}/Common/Faces/CullRulledFace.d.ts +0 -0
  300. /package/Mesher/{Models → Voxels/Models}/Common/Faces/ShadeRulelessFace.js +0 -0
  301. /package/Mesher/{Models → Voxels/Models}/Common/GetTexture.js +0 -0
  302. /package/Mesher/{Models → Voxels/Models}/Nodes/Custom/index.d.ts +0 -0
  303. /package/Mesher/{Models → Voxels/Models}/Nodes/Custom/index.js +0 -0
  304. /package/Mesher/{Models → Voxels/Models}/Nodes/GeometryNode.d.ts +0 -0
  305. /package/Mesher/{Models → Voxels/Models}/Nodes/GeometryNode.js +0 -0
  306. /package/Mesher/{Models → Voxels/Models}/Nodes/Types/GeomtryNode.types.d.ts +0 -0
  307. /package/Mesher/{Models → Voxels/Models}/Nodes/Types/GeomtryNode.types.js +0 -0
  308. /package/Mesher/{Models → Voxels/Models}/Nodes/Types/QuadVoxelGometryNodeTypes.js +0 -0
  309. /package/Mesher/{Models → Voxels/Models}/Nodes/Types/TriangleVoxelGometryNodeTypes.js +0 -0
  310. /package/Mesher/{Models → Voxels/Models}/Nodes/VoxelGeometryConstructor.js +0 -0
  311. /package/Mesher/{Models → Voxels/Models}/Procedures/TextureProcedure.js +0 -0
  312. /package/Mesher/{Models → Voxels/Models}/Procedures/TextureProcedureRegister.d.ts +0 -0
  313. /package/Mesher/{Models → Voxels/Models}/RenderedMaterials.d.ts +0 -0
  314. /package/Mesher/{Models → Voxels/Models}/RenderedMaterials.js +0 -0
  315. /package/Templates/Selection/{VoxelSelecton.js → VoxelSelection.js} +0 -0
@@ -1,10 +1,9 @@
1
1
  import { VoxelBuildSpace } from "../../VoxelBuildSpace";
2
- import { BasicVoxelShapeTemplate } from "../../../Templates/Shapes/BasicVoxelShapeTemplate";
3
- import { VoxelTemplateSelection } from "../../../Templates/Selection/VoxelTemplateSelection";
2
+ import { VoxelShapeTemplate } from "../../../Templates/Shapes/VoxelShapeTemplate";
4
3
  import { VoxelPickResult } from "../../../Voxels/Interaction/VoxelPickResult";
5
4
  import { Vector3Like } from "@amodx/math";
6
5
  import { PaintVoxelData } from "../../../Voxels";
7
- import { BuilderToolBase } from "../BuilderToolBase";
6
+ import { BuilderToolBase, ToolOptionsData } from "../BuilderToolBase";
8
7
  export declare enum BrushPositionModes {
9
8
  Start = "Start",
10
9
  Center = "Center",
@@ -25,24 +24,32 @@ interface BrushToolEvents {
25
24
  "shape-updated": null;
26
25
  }
27
26
  export declare class BrushTool extends BuilderToolBase<BrushToolEvents> {
28
- space: VoxelBuildSpace;
29
27
  static ToolId: string;
30
28
  static ModeArray: BrushToolModes[];
31
29
  static PositionModeArray: BrushPositionModes[];
32
30
  static get ShapesArray(): string[];
33
- static ShapeCreators: Record<string, () => BasicVoxelShapeTemplate<any, any, any>>;
31
+ static ShapeCreators: Record<string, () => VoxelShapeTemplate>;
32
+ static BaseToolOptions: ToolOptionsData;
33
+ static ShapeOptions: Record<string, () => ToolOptionsData>;
34
34
  shape: string;
35
35
  axisXPositionMode: BrushPositionModes;
36
36
  axisYPositionMode: BrushPositionModes;
37
37
  axisZPositionMode: BrushPositionModes;
38
38
  mode: BrushToolModes;
39
- template: BasicVoxelShapeTemplate<any, any, any>;
40
- selection: VoxelTemplateSelection;
39
+ template: VoxelShapeTemplate;
40
+ get selection(): import("../../../Templates/Shapes/Selections/VoxelShapeSelection").IVoxelShapeSelection<any, import("../../../Templates/Shapes/Selections/VoxelShapeSelection").IVoxelShapeSelectionData<any>>;
41
+ voxelData: Partial<BrushVoxelData>;
42
+ usePlacingStrategy: boolean;
43
+ placePosition: Vector3Like;
41
44
  protected _position: Vector3Like;
42
45
  constructor(space: VoxelBuildSpace);
43
- use(picked: VoxelPickResult, voxelData?: Partial<BrushVoxelData>, usePlacingStrategy?: boolean): Promise<true | undefined>;
46
+ update(): Promise<void>;
47
+ cancel(): void;
48
+ use(): Promise<void>;
44
49
  protected getPlacePosition(picked: VoxelPickResult): Vector3Like;
45
- updatePlacer(picked: VoxelPickResult): false | undefined;
46
50
  updateShape(shape: string): void;
51
+ getOptionValue(property: string): any;
52
+ getCurrentOptions(): ToolOptionsData;
53
+ updateOption(property: string, value: any): void;
47
54
  }
48
55
  export {};
@@ -1,10 +1,10 @@
1
- import { VoxelTemplateSelection } from "../../../Templates/Selection/VoxelTemplateSelection";
2
- import { SphereVoxelTemplate } from "../../../Templates/Shapes/SphereVoxelTemplate";
3
- import { BoxVoxelTemplate } from "../../../Templates/Shapes/BoxVoxelTemplate";
4
- import { PyramidVoxelTemplate } from "../../../Templates/Shapes/PyramidVoxelTemplate";
1
+ import { VoxelShapeTemplate } from "../../../Templates/Shapes/VoxelShapeTemplate";
2
+ import { SphereVoxelShapeSelection } from "../../../Templates/Shapes/Selections/SphereVoxelShapeSelection";
3
+ import { BoxVoxelShapeSelection } from "../../../Templates/Shapes/Selections/BoxVoxelShapeSelection";
4
+ import { PyramidVoxelShapeSelection } from "../../../Templates/Shapes/Selections/PyramidVoxelShapeSelection";
5
+ import { EllipsoidVoxelShapeSelection } from "../../../Templates/Shapes/Selections/EllipsoidVoxelShapeSelection";
5
6
  import { Vector3Like } from "@amodx/math";
6
7
  import { BuilderToolBase } from "../BuilderToolBase";
7
- import { EllipsoidVoxelTemplate } from "../../../Templates/Shapes/EllipsoidVoxelTemplate";
8
8
  export var BrushPositionModes;
9
9
  (function (BrushPositionModes) {
10
10
  BrushPositionModes["Start"] = "Start";
@@ -18,7 +18,6 @@ export var BrushToolModes;
18
18
  BrushToolModes["Remove"] = "Remove";
19
19
  })(BrushToolModes || (BrushToolModes = {}));
20
20
  export class BrushTool extends BuilderToolBase {
21
- space;
22
21
  static ToolId = "Brush";
23
22
  static ModeArray = [
24
23
  BrushToolModes.Fill,
@@ -34,17 +33,164 @@ export class BrushTool extends BuilderToolBase {
34
33
  return Object.keys(this.ShapeCreators);
35
34
  }
36
35
  static ShapeCreators = {
37
- Sphere: () => {
38
- return new SphereVoxelTemplate(SphereVoxelTemplate.CreateNew({}));
36
+ Sphere() {
37
+ return new VoxelShapeTemplate(VoxelShapeTemplate.CreateNew({
38
+ shapeSelection: SphereVoxelShapeSelection.CreateNew({}),
39
+ }));
39
40
  },
40
- Box: () => {
41
- return new BoxVoxelTemplate(BoxVoxelTemplate.CreateNew({}));
41
+ Box() {
42
+ return new VoxelShapeTemplate(VoxelShapeTemplate.CreateNew({
43
+ shapeSelection: BoxVoxelShapeSelection.CreateNew({}),
44
+ }));
42
45
  },
43
- Pyramid: () => {
44
- return new PyramidVoxelTemplate(PyramidVoxelTemplate.CreateNew({}));
46
+ Pyramid() {
47
+ return new VoxelShapeTemplate(VoxelShapeTemplate.CreateNew({
48
+ shapeSelection: PyramidVoxelShapeSelection.CreateNew({}),
49
+ }));
45
50
  },
46
- Ellipsoid: () => {
47
- return new EllipsoidVoxelTemplate(EllipsoidVoxelTemplate.CreateNew({}));
51
+ Ellipsoid() {
52
+ return new VoxelShapeTemplate(VoxelShapeTemplate.CreateNew({
53
+ shapeSelection: EllipsoidVoxelShapeSelection.CreateNew({}),
54
+ }));
55
+ },
56
+ };
57
+ static BaseToolOptions = [
58
+ {
59
+ cateogry: "main",
60
+ property: "axisXPositionMode",
61
+ name: "X Axis Position Mode",
62
+ type: "string",
63
+ options: [
64
+ ["End", BrushPositionModes.End],
65
+ ["Center", BrushPositionModes.Center],
66
+ ["Start", BrushPositionModes.Start],
67
+ ],
68
+ },
69
+ {
70
+ cateogry: "main",
71
+ property: "axisYPositionMode",
72
+ name: "Y Axis Position Mode",
73
+ type: "string",
74
+ options: [
75
+ ["End", BrushPositionModes.End],
76
+ ["Center", BrushPositionModes.Center],
77
+ ["Start", BrushPositionModes.Start],
78
+ ],
79
+ },
80
+ {
81
+ cateogry: "main",
82
+ property: "axisZPositionMode",
83
+ name: "Z Axis Position Mode",
84
+ type: "string",
85
+ options: [
86
+ ["End", BrushPositionModes.End],
87
+ ["Center", BrushPositionModes.Center],
88
+ ["Start", BrushPositionModes.Start],
89
+ ],
90
+ },
91
+ ];
92
+ static ShapeOptions = {
93
+ Sphere() {
94
+ return [
95
+ {
96
+ cateogry: "shape",
97
+ property: "radius",
98
+ name: "Radius",
99
+ type: "number",
100
+ min: 0,
101
+ max: 50,
102
+ },
103
+ ];
104
+ },
105
+ Box() {
106
+ return [
107
+ {
108
+ cateogry: "shape",
109
+ property: "width",
110
+ name: "Width",
111
+ type: "number",
112
+ min: 0,
113
+ max: 50,
114
+ },
115
+ {
116
+ cateogry: "shape",
117
+ property: "height",
118
+ name: "Height",
119
+ type: "number",
120
+ min: 0,
121
+ max: 50,
122
+ },
123
+ {
124
+ cateogry: "shape",
125
+ property: "depth",
126
+ name: "Depth",
127
+ type: "number",
128
+ min: 0,
129
+ max: 50,
130
+ },
131
+ ];
132
+ },
133
+ Pyramid() {
134
+ return [
135
+ {
136
+ cateogry: "shape",
137
+ property: "direction",
138
+ name: "Direction",
139
+ type: "string",
140
+ options: [
141
+ ["Up", "+y"],
142
+ ["Down", "-y"],
143
+ ["East", "+x"],
144
+ ["West", "-x"],
145
+ ["North", "+z"],
146
+ ["South", "-z"],
147
+ ],
148
+ },
149
+ {
150
+ cateogry: "shape",
151
+ property: "height",
152
+ name: "Height",
153
+ type: "number",
154
+ min: 0,
155
+ max: 50,
156
+ },
157
+ {
158
+ cateogry: "shape",
159
+ property: "fallOff",
160
+ name: "Falloff",
161
+ type: "number",
162
+ min: 0,
163
+ max: 50,
164
+ },
165
+ ];
166
+ },
167
+ Ellipsoid() {
168
+ return [
169
+ {
170
+ cateogry: "shape",
171
+ property: "radiusX",
172
+ name: "Radius X",
173
+ type: "number",
174
+ min: 0,
175
+ max: 50,
176
+ },
177
+ {
178
+ cateogry: "shape",
179
+ property: "radiusY",
180
+ name: "Radius Y",
181
+ type: "number",
182
+ min: 0,
183
+ max: 50,
184
+ },
185
+ {
186
+ cateogry: "shape",
187
+ property: "radiusZ",
188
+ name: "Radius Z",
189
+ type: "number",
190
+ min: 0,
191
+ max: 50,
192
+ },
193
+ ];
48
194
  },
49
195
  };
50
196
  shape = "Sphere";
@@ -53,94 +199,154 @@ export class BrushTool extends BuilderToolBase {
53
199
  axisZPositionMode = BrushPositionModes.Center;
54
200
  mode = BrushToolModes.Fill;
55
201
  template;
56
- selection;
202
+ get selection() {
203
+ return this.template.shapeSelection;
204
+ }
205
+ voxelData = {};
206
+ usePlacingStrategy = true;
207
+ placePosition = Vector3Like.Create();
57
208
  _position = Vector3Like.Create();
58
209
  constructor(space) {
59
- super();
60
- this.space = space;
61
- this.selection = new VoxelTemplateSelection();
210
+ super(space);
62
211
  this.updateShape(this.shape);
63
212
  }
64
- async use(picked, voxelData = {}, usePlacingStrategy = true) {
65
- if (usePlacingStrategy) {
66
- if (voxelData.fill) {
67
- const newData = this.space.getPlaceState(voxelData.fill, picked);
68
- if (newData)
69
- voxelData.fill = newData;
213
+ async update() {
214
+ this._lastPicked = await this.space.pickWithProvider(this.rayProviderIndex);
215
+ if (!this._lastPicked)
216
+ return;
217
+ if (this.mode == BrushToolModes.Fill ||
218
+ this.mode == BrushToolModes.Extrude) {
219
+ if (!this.space.bounds.intersectsPoint(this._lastPicked.normalPosition)) {
220
+ this._lastPicked = null;
221
+ return;
70
222
  }
71
223
  }
72
- if (this.mode == BrushToolModes.Fill && voxelData.fill) {
73
- if (!this.space.bounds.intersectsPoint(picked.normalPosition))
224
+ if (this.mode == BrushToolModes.Remove) {
225
+ if (!this.space.bounds.intersectsPoint(this._lastPicked.position)) {
226
+ this._lastPicked = null;
74
227
  return;
75
- this.template.setVoxels(voxelData.fill);
76
- const place = this.getPlacePosition(picked);
228
+ }
229
+ }
230
+ const place = this.getPlacePosition(this._lastPicked);
231
+ this.placePosition.x = place.x;
232
+ this.placePosition.y = place.y;
233
+ this.placePosition.z = place.z;
234
+ this.selection.origin.x = place.x;
235
+ this.selection.origin.y = place.y;
236
+ this.selection.origin.z = place.z;
237
+ }
238
+ cancel() {
239
+ this._lastPicked = null;
240
+ }
241
+ async use() {
242
+ if (!this._lastPicked)
243
+ return;
244
+ if (this.usePlacingStrategy) {
245
+ if (this.voxelData.fill) {
246
+ const newData = this.space.getPlaceState(this.voxelData.fill, this._lastPicked);
247
+ if (newData)
248
+ this.voxelData.fill = newData;
249
+ }
250
+ }
251
+ if (this.mode == BrushToolModes.Fill && this.voxelData.fill) {
252
+ this.template.setVoxels(this.voxelData.fill);
253
+ const place = this.getPlacePosition(this._lastPicked);
77
254
  await this.space.paintTemplate([place.x, place.y, place.z], this.template.toJSON());
255
+ return;
256
+ }
257
+ if (this.mode == BrushToolModes.Extrude) {
258
+ const template = await this.space.getExtrudedSelectionTemplate(this.selection.toJSON(), this._lastPicked.normal);
259
+ await this.space.paintTemplate(this.selection.origin, template.toJSON());
260
+ return;
78
261
  }
79
262
  if (this.mode == BrushToolModes.Remove) {
80
- if (!this.space.bounds.intersectsPoint(picked.position))
81
- return;
82
- const voxel = picked.voxel;
263
+ const voxel = this._lastPicked.voxel;
83
264
  if (voxel && !voxel.isAir()) {
84
- const place = this.getPlacePosition(picked);
265
+ const place = this.getPlacePosition(this._lastPicked);
85
266
  await this.space.eraseTemplate([place.x, place.y, place.z], this.template.toJSON());
86
267
  }
87
- return true;
268
+ return;
88
269
  }
89
270
  }
90
271
  getPlacePosition(picked) {
91
272
  //x
92
273
  if (this.axisXPositionMode == BrushPositionModes.Center) {
93
274
  this._position.x =
94
- picked.normalPosition.x - Math.floor(this.template.bounds.size.x / 2);
275
+ picked.normalPosition.x -
276
+ Math.floor(this.template.shapeSelection.bounds.size.x / 2);
95
277
  }
96
278
  if (this.axisXPositionMode == BrushPositionModes.Start) {
97
279
  this._position.x = picked.normalPosition.x;
98
280
  }
99
281
  if (this.axisXPositionMode == BrushPositionModes.End) {
100
- this._position.x = picked.normalPosition.x - this.template.bounds.size.x;
282
+ this._position.x =
283
+ picked.normalPosition.x - this.template.shapeSelection.bounds.size.x;
101
284
  }
102
285
  //y
103
286
  if (this.axisYPositionMode == BrushPositionModes.Center) {
104
287
  this._position.y =
105
- picked.normalPosition.y - Math.floor(this.template.bounds.size.y / 2);
288
+ picked.normalPosition.y -
289
+ Math.floor(this.template.shapeSelection.bounds.size.y / 2);
106
290
  }
107
291
  if (this.axisYPositionMode == BrushPositionModes.Start) {
108
292
  this._position.y = picked.normalPosition.y;
109
293
  }
110
294
  if (this.axisYPositionMode == BrushPositionModes.End) {
111
- this._position.y = picked.normalPosition.y - this.template.bounds.size.y;
295
+ this._position.y =
296
+ picked.normalPosition.y - this.template.shapeSelection.bounds.size.y;
112
297
  }
113
298
  //z
114
299
  if (this.axisZPositionMode == BrushPositionModes.Center) {
115
300
  this._position.z =
116
- picked.normalPosition.z - Math.floor(this.template.bounds.size.z / 2);
301
+ picked.normalPosition.z -
302
+ Math.floor(this.template.shapeSelection.bounds.size.z / 2);
117
303
  }
118
304
  if (this.axisZPositionMode == BrushPositionModes.Start) {
119
305
  this._position.z = picked.normalPosition.z;
120
306
  }
121
307
  if (this.axisXPositionMode == BrushPositionModes.End) {
122
- this._position.z = picked.normalPosition.z - this.template.bounds.size.z;
308
+ this._position.z =
309
+ picked.normalPosition.z - this.template.shapeSelection.bounds.size.z;
123
310
  }
124
311
  return this._position;
125
312
  }
126
- updatePlacer(picked) {
127
- const place = this.getPlacePosition(picked);
128
- if (!this.space.bounds.intersectsPoint(place))
129
- return false;
130
- this.selection.origin.x = place.x;
131
- this.selection.origin.y = place.y;
132
- this.selection.origin.z = place.z;
133
- }
134
313
  updateShape(shape) {
135
314
  const shapeCreator = BrushTool.ShapeCreators[shape];
136
315
  if (!shapeCreator)
137
316
  throw new Error(`Shape with id ${shape} does not exist`);
138
317
  this.shape = shape;
139
318
  this.template = shapeCreator();
140
- this.selection.setTemplate(this.template);
141
- this.template.addEventListener("updated", () => {
142
- this.selection.setTemplate(this.template);
143
- this.dispatch("shape-updated", null);
144
- });
319
+ }
320
+ getOptionValue(property) {
321
+ const data = this.getOptionData(property);
322
+ if (!data)
323
+ return;
324
+ if (this.optionInCategory(property, "main")) {
325
+ return this[data.property];
326
+ }
327
+ if (this.optionInCategory(property, "shape")) {
328
+ return this.selection[data.property];
329
+ }
330
+ }
331
+ getCurrentOptions() {
332
+ const options = [
333
+ ...BrushTool.BaseToolOptions,
334
+ ...BrushTool.ShapeOptions[this.shape](),
335
+ ];
336
+ this.processOptions(options);
337
+ return options;
338
+ }
339
+ updateOption(property, value) {
340
+ const data = this.getOptionData(property);
341
+ if (!data)
342
+ return;
343
+ if (this.optionInCategory(property, "main")) {
344
+ this[data.property] = value;
345
+ return;
346
+ }
347
+ if (this.optionInCategory(property, "shape")) {
348
+ this.selection[data.property] = value;
349
+ return;
350
+ }
145
351
  }
146
352
  }
@@ -1,3 +1,39 @@
1
+ import { VoxelPickResult } from "Voxels/Interaction/VoxelPickResult";
1
2
  import { TypedEventTarget } from "../../Util/TypedEventTarget";
3
+ import { VoxelBuildSpace } from "../VoxelBuildSpace";
4
+ type ToolOptionBase<Data> = {
5
+ cateogry: string;
6
+ property: string;
7
+ name: string;
8
+ } & Data;
9
+ export type ToolOption = ToolOptionBase<{
10
+ type: "string";
11
+ options: [name: string, value: any][];
12
+ }> | ToolOptionBase<{
13
+ type: "number";
14
+ min: number;
15
+ max: number;
16
+ }>;
17
+ export type ToolOptionsData = ToolOption[];
2
18
  export declare abstract class BuilderToolBase<Events extends Record<string, any>> extends TypedEventTarget<Events> {
19
+ space: VoxelBuildSpace;
20
+ rayProviderIndex: number;
21
+ protected _lastPicked: VoxelPickResult | null;
22
+ get picked(): Readonly<VoxelPickResult> | null;
23
+ constructor(space: VoxelBuildSpace);
24
+ protected _options: ToolOptionsData;
25
+ protected _optionsMap: Map<string, ToolOption>;
26
+ protected _categoryMap: Map<string, Set<string>>;
27
+ protected processOptions(data: ToolOptionsData): void;
28
+ getOptions(): ToolOptionsData;
29
+ getOptionCategories(): [string, Set<string>][];
30
+ abstract getOptionValue(id: string): any;
31
+ getOptionData(id: string): ToolOption | undefined;
32
+ optionInCategory(option: string, cateogry: string): boolean;
33
+ abstract getCurrentOptions(): ToolOptionsData;
34
+ abstract updateOption(property: string, value: any): void;
35
+ abstract cancel(): void;
36
+ abstract use(...args: any): Promise<void>;
37
+ abstract update(...args: any): Promise<void>;
3
38
  }
39
+ export {};
@@ -1,3 +1,42 @@
1
1
  import { TypedEventTarget } from "../../Util/TypedEventTarget";
2
2
  export class BuilderToolBase extends TypedEventTarget {
3
+ space;
4
+ rayProviderIndex = 0;
5
+ _lastPicked = null;
6
+ get picked() {
7
+ return this._lastPicked;
8
+ }
9
+ constructor(space) {
10
+ super();
11
+ this.space = space;
12
+ }
13
+ _options = [];
14
+ _optionsMap = new Map();
15
+ _categoryMap = new Map();
16
+ processOptions(data) {
17
+ this._options = data;
18
+ this._optionsMap.clear();
19
+ this._categoryMap.clear();
20
+ for (const option of data) {
21
+ let categoryArray = this._categoryMap.get(option.cateogry);
22
+ if (!categoryArray) {
23
+ categoryArray = new Set();
24
+ this._categoryMap.set(option.cateogry, categoryArray);
25
+ }
26
+ categoryArray.add(option.property);
27
+ this._optionsMap.set(option.property, option);
28
+ }
29
+ }
30
+ getOptions() {
31
+ return this._options;
32
+ }
33
+ getOptionCategories() {
34
+ return [...this._categoryMap];
35
+ }
36
+ getOptionData(id) {
37
+ return this._optionsMap.get(id);
38
+ }
39
+ optionInCategory(option, cateogry) {
40
+ return Boolean(this._categoryMap.get(cateogry)?.has(option));
41
+ }
3
42
  }
@@ -1,8 +1,6 @@
1
- import { VoxelPickResult } from "../../../Voxels/Interaction/VoxelPickResult";
2
- import { VoxelBuildSpace } from "../../VoxelBuildSpace";
3
1
  import { PaintVoxelData } from "../../../Voxels";
4
2
  import { VoxelPointSelection } from "../../../Templates/Selection/VoxelPointSelection";
5
- import { BuilderToolBase } from "../BuilderToolBase";
3
+ import { BuilderToolBase, ToolOptionsData } from "../BuilderToolBase";
6
4
  export declare enum HandToolModes {
7
5
  Place = "Place",
8
6
  Remove = "Remove"
@@ -10,13 +8,17 @@ export declare enum HandToolModes {
10
8
  interface HandToolEvents {
11
9
  }
12
10
  export declare class HandTool extends BuilderToolBase<HandToolEvents> {
13
- space: VoxelBuildSpace;
14
11
  static ToolId: string;
15
12
  static ModeArray: HandToolModes[];
16
13
  mode: HandToolModes;
17
14
  selection: VoxelPointSelection;
18
- constructor(space: VoxelBuildSpace);
19
- updatePlacer(picked: VoxelPickResult): void;
20
- use(picked: VoxelPickResult, voxelData: PaintVoxelData, usePlacingStrategy?: boolean): Promise<boolean | undefined>;
15
+ voxelData: PaintVoxelData;
16
+ usePlacingStrategy: boolean;
17
+ update(): Promise<void>;
18
+ cancel(): void;
19
+ use(): Promise<void>;
20
+ getOptionValue(id: string): null;
21
+ getCurrentOptions(): ToolOptionsData;
22
+ updateOption(property: string, value: any): void;
21
23
  }
22
24
  export {};
@@ -6,7 +6,6 @@ export var HandToolModes;
6
6
  HandToolModes["Remove"] = "Remove";
7
7
  })(HandToolModes || (HandToolModes = {}));
8
8
  export class HandTool extends BuilderToolBase {
9
- space;
10
9
  static ToolId = "Hand";
11
10
  static ModeArray = [
12
11
  HandToolModes.Place,
@@ -14,43 +13,61 @@ export class HandTool extends BuilderToolBase {
14
13
  ];
15
14
  mode = HandToolModes.Place;
16
15
  selection = new VoxelPointSelection();
17
- constructor(space) {
18
- super();
19
- this.space = space;
20
- }
21
- updatePlacer(picked) {
16
+ voxelData;
17
+ usePlacingStrategy = true;
18
+ async update() {
19
+ this._lastPicked = await this.space.pickWithProvider(this.rayProviderIndex);
20
+ if (!this._lastPicked)
21
+ return;
22
22
  if (this.mode == HandToolModes.Place) {
23
- this.selection.reConstruct(picked.normalPosition);
23
+ if (!this.space.bounds.intersectsPoint(this._lastPicked.normalPosition)) {
24
+ this._lastPicked = null;
25
+ return;
26
+ }
27
+ this.selection.reConstruct(this._lastPicked.normalPosition);
24
28
  }
25
29
  if (this.mode == HandToolModes.Remove) {
26
- this.selection.reConstruct(picked.position);
30
+ if (!this.space.bounds.intersectsPoint(this._lastPicked.position)) {
31
+ this._lastPicked = null;
32
+ return;
33
+ }
34
+ this.selection.reConstruct(this._lastPicked.position);
27
35
  }
28
36
  }
29
- async use(picked, voxelData, usePlacingStrategy = true) {
37
+ cancel() {
38
+ this._lastPicked = null;
39
+ }
40
+ async use() {
41
+ if (!this._lastPicked)
42
+ return;
30
43
  if (this.mode == HandToolModes.Place) {
31
- if (!this.space.bounds.intersectsPoint(picked.normalPosition))
32
- return false;
33
- if (usePlacingStrategy) {
34
- const newData = this.space.getPlaceState(voxelData, picked);
44
+ let voxelData = this.voxelData;
45
+ if (this.usePlacingStrategy) {
46
+ const newData = this.space.getPlaceState(voxelData, this._lastPicked);
35
47
  if (newData)
36
48
  voxelData = newData;
37
49
  }
38
50
  await this.space.paintVoxel([
39
- picked.normalPosition.x,
40
- picked.normalPosition.y,
41
- picked.normalPosition.z,
51
+ this._lastPicked.normalPosition.x,
52
+ this._lastPicked.normalPosition.y,
53
+ this._lastPicked.normalPosition.z,
42
54
  ], voxelData);
43
- return true;
55
+ return;
44
56
  }
45
57
  if (this.mode == HandToolModes.Remove) {
46
- if (!this.space.bounds.intersectsPoint(picked.position))
47
- return false;
48
58
  await this.space.eraseVoxel([
49
- picked.position.x,
50
- picked.position.y,
51
- picked.position.z,
59
+ this._lastPicked.position.x,
60
+ this._lastPicked.position.y,
61
+ this._lastPicked.position.z,
52
62
  ]);
53
- return true;
63
+ return;
54
64
  }
55
65
  }
66
+ getOptionValue(id) {
67
+ return null;
68
+ }
69
+ getCurrentOptions() {
70
+ return [];
71
+ }
72
+ updateOption(property, value) { }
56
73
  }