@divinevoxel/vlox 0.0.75 → 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 (330) hide show
  1. package/Builder/RayProvider.d.ts +6 -0
  2. package/Builder/Tools/Brush/BrushTool.d.ts +55 -0
  3. package/Builder/Tools/Brush/BrushTool.js +352 -0
  4. package/Builder/Tools/BuilderToolBase.d.ts +39 -0
  5. package/Builder/Tools/BuilderToolBase.js +42 -0
  6. package/Builder/Tools/Hand/HandTool.d.ts +24 -0
  7. package/Builder/Tools/Hand/HandTool.js +73 -0
  8. package/Builder/Tools/Path/PahtTool.d.ts +34 -0
  9. package/Builder/Tools/Path/PahtTool.js +128 -0
  10. package/Builder/Tools/Sculpt/SculptTool.d.ts +34 -0
  11. package/Builder/Tools/Sculpt/SculptTool.js +102 -0
  12. package/Builder/Tools/Shape/ShapeTool.d.ts +32 -0
  13. package/Builder/Tools/Shape/ShapeTool.js +78 -0
  14. package/Builder/Tools/Template/TemplateTool.d.ts +35 -0
  15. package/Builder/Tools/Template/TemplateTool.js +73 -0
  16. package/Builder/Tools/Wand/WandTool.d.ts +30 -0
  17. package/Builder/Tools/Wand/WandTool.js +90 -0
  18. package/Builder/Tools/Wrench/WrenchTool.d.ts +47 -0
  19. package/Builder/Tools/Wrench/WrenchTool.js +184 -0
  20. package/Builder/Util/FreeBoxSelection.d.ts +12 -0
  21. package/Builder/Util/FreeBoxSelection.js +21 -0
  22. package/Builder/Util/FreePointSelection.d.ts +14 -0
  23. package/Builder/Util/FreePointSelection.js +39 -0
  24. package/Builder/Util/SurfaceBoxSelection.d.ts +12 -0
  25. package/Builder/Util/SurfaceBoxSelection.js +25 -0
  26. package/Builder/VoxelBuildSpace.d.ts +73 -0
  27. package/Builder/VoxelBuildSpace.js +224 -0
  28. package/Builder/World/InitTasks.d.ts +1 -0
  29. package/Builder/World/InitTasks.js +129 -0
  30. package/Builder/World/VoxelBuildSpaceWorld.d.ts +4 -0
  31. package/Builder/World/VoxelBuildSpaceWorld.js +10 -0
  32. package/Contexts/Render/DivineVoxelEngineRender.d.ts +5 -5
  33. package/Contexts/World/DivineVoxelEngineWorld.d.ts +5 -5
  34. package/Mesher/Geomtry/Proto/ProtoMesh.d.ts +18 -0
  35. package/Mesher/Geomtry/Proto/ProtoMesh.js +73 -0
  36. package/Mesher/Geomtry/{VoxelMeshBuffers.d.ts → Proto/ProtoMeshBuffer.d.ts} +2 -2
  37. package/Mesher/Geomtry/{VoxelMeshBuffers.js → Proto/ProtoMeshBuffer.js} +2 -2
  38. package/Mesher/Geomtry/Shapes/Box.d.ts +2 -9
  39. package/Mesher/Geomtry/Shapes/Box.js +7 -12
  40. package/Mesher/Geomtry/Transform/TransformBox.js +5 -2
  41. package/Mesher/InitMesher.js +4 -4
  42. package/Mesher/InitTask.js +2 -2
  43. package/Mesher/Items/Base/CompactItemMesh.d.ts +3 -0
  44. package/Mesher/Items/Base/CompactItemMesh.js +20 -0
  45. package/Mesher/Items/Geomtry/ItemGeometryBuilder.d.ts +5 -0
  46. package/Mesher/Items/Geomtry/ItemGeometryBuilder.js +131 -0
  47. package/Mesher/Items/Geomtry/ItemMeshVertexStructCursor.d.ts +48 -0
  48. package/Mesher/Items/Geomtry/ItemMeshVertexStructCursor.js +114 -0
  49. package/Mesher/Items/MeshTexture.d.ts +1 -0
  50. package/Mesher/Items/MeshTexture.js +214 -0
  51. package/Mesher/Items/MeshTextureO.js +277 -0
  52. package/Mesher/Items/Models/ItemModelBuilder.d.ts +27 -0
  53. package/Mesher/Items/Models/ItemModelBuilder.js +64 -0
  54. package/Mesher/Types/ItemMesh.types.d.ts +5 -0
  55. package/Mesher/Types/ItemMesh.types.js +12 -0
  56. package/Mesher/Types/Mesher.types.d.ts +15 -9
  57. package/Mesher/Types/Mesher.types.js +14 -0
  58. package/Mesher/Types/VoxelMesh.types.js +7 -6
  59. package/Mesher/Voxels/Base/CompactTemplateMesh.d.ts +3 -0
  60. package/Mesher/{Functions/CompactVoxelMesh.js → Voxels/Base/CompactTemplateMesh.js} +4 -40
  61. package/Mesher/{Functions → Voxels/Base}/CompactVoxelSectionMesh.d.ts +2 -2
  62. package/Mesher/{Functions → Voxels}/Base/MeshSectionBase.d.ts +1 -1
  63. package/Mesher/{Functions → Voxels}/Base/MeshSectionBase.js +11 -7
  64. package/Mesher/{Geomtry → Voxels/Geomtry}/CompactedSectionVoxelMesh.d.ts +1 -1
  65. package/Mesher/{Geomtry → Voxels/Geomtry}/CompactedSectionVoxelMesh.js +1 -1
  66. package/Mesher/{Geomtry → Voxels/Geomtry}/VoxelGeometryBuilder.d.ts +2 -2
  67. package/Mesher/{Geomtry → Voxels/Geomtry}/VoxelGeometryBuilder.js +1 -1
  68. package/Mesher/{Geomtry → Voxels/Geomtry}/VoxelMeshBVHBuilder.d.ts +3 -3
  69. package/Mesher/{Geomtry → Voxels/Geomtry}/VoxelMeshBVHBuilder.js +2 -2
  70. package/Mesher/Voxels/MeshTemplate.d.ts +3 -0
  71. package/Mesher/Voxels/MeshTemplate.js +81 -0
  72. package/Mesher/{Functions → Voxels}/MeshVoxel.d.ts +1 -1
  73. package/Mesher/{Functions → Voxels}/MeshVoxel.js +6 -4
  74. package/Mesher/{Models → Voxels/Models}/Common/Calc/CalcConstants.d.ts +3 -3
  75. package/Mesher/{Models → Voxels/Models}/Common/Calc/CalcConstants.js +4 -4
  76. package/Mesher/{Models → Voxels/Models}/Common/Calc/FaceDataCalc.d.ts +1 -1
  77. package/Mesher/{Models → Voxels/Models}/Common/Calc/FaceDataCalc.js +2 -2
  78. package/Mesher/{Models → Voxels/Models}/Common/Faces/CullRulledFace.js +1 -1
  79. package/Mesher/{Models → Voxels/Models}/Common/Faces/ShadeRulelessFace.d.ts +1 -1
  80. package/Mesher/{Models → Voxels/Models}/Common/Faces/ShadeRulledFace.d.ts +1 -1
  81. package/Mesher/{Models → Voxels/Models}/Common/Faces/ShadeRulledFace.js +1 -1
  82. package/Mesher/{Models → Voxels/Models}/Common/GetTexture.d.ts +3 -3
  83. package/Mesher/{Models → Voxels/Models}/Nodes/Custom/Liquid/FlowGradient.d.ts +1 -1
  84. package/Mesher/{Models → Voxels/Models}/Nodes/Custom/Liquid/FlowGradient.js +1 -1
  85. package/Mesher/{Models → Voxels/Models}/Nodes/Custom/Liquid/LiquidGeomtryNode.d.ts +3 -3
  86. package/Mesher/{Models → Voxels/Models}/Nodes/Custom/Liquid/LiquidGeomtryNode.js +14 -16
  87. package/Mesher/{Models → Voxels/Models}/Nodes/Default/QuadVoxelGeometryNode.d.ts +2 -2
  88. package/Mesher/{Models → Voxels/Models}/Nodes/Default/QuadVoxelGeometryNode.js +1 -1
  89. package/Mesher/{Models → Voxels/Models}/Nodes/Default/TriangleVoxelGeometryNode.d.ts +2 -2
  90. package/Mesher/{Models → Voxels/Models}/Nodes/Default/TriangleVoxelGeometryNode.js +1 -1
  91. package/Mesher/{Models → Voxels/Models}/Nodes/Types/QuadVoxelGometryNodeTypes.d.ts +2 -2
  92. package/Mesher/{Models → Voxels/Models}/Nodes/Types/TriangleVoxelGometryNodeTypes.d.ts +1 -1
  93. package/Mesher/{Models → Voxels/Models}/Nodes/VoxelGeometryConstructor.d.ts +2 -2
  94. package/Mesher/Voxels/Models/Procedures/Default/ConsistentRotationTextureProcedure.d.ts +24 -0
  95. package/Mesher/{Models → Voxels/Models}/Procedures/Default/ConsistentRotationTextureProcedure.js +2 -2
  96. package/Mesher/{Models → Voxels/Models}/Procedures/Default/OutlinedTextureProcedure.d.ts +4 -5
  97. package/Mesher/Voxels/Models/Procedures/Default/OutlinedTextureProcedure.js +205 -0
  98. package/Mesher/Voxels/Models/Procedures/Default/PillarTextureProcedure.d.ts +28 -0
  99. package/Mesher/Voxels/Models/Procedures/Default/PillarTextureProcedure.js +109 -0
  100. package/Mesher/{Models → Voxels/Models}/Procedures/TextureProcedure.d.ts +3 -3
  101. package/Mesher/{Models → Voxels/Models}/Procedures/TextureProcedureRegister.js +2 -0
  102. package/Mesher/{Models → Voxels/Models}/VoxelConstructor.d.ts +4 -4
  103. package/Mesher/{Models → Voxels/Models}/VoxelConstructor.js +3 -3
  104. package/Mesher/{Models → Voxels/Models}/VoxelGeometryBuilderCacheSpace.d.ts +2 -2
  105. package/Mesher/{Models → Voxels/Models}/VoxelGeometryBuilderCacheSpace.js +2 -2
  106. package/Mesher/{Models → Voxels/Models}/VoxelModelBuilder.d.ts +7 -7
  107. package/Mesher/{Models → Voxels/Models}/VoxelModelBuilder.js +6 -5
  108. package/Mesher/{Models → Voxels/Models}/VoxelModelConstructorRegister.d.ts +4 -4
  109. package/Mesher/{Models → Voxels/Models}/VoxelModelConstructorRegister.js +2 -2
  110. package/Mesher/{Models → Voxels/Models}/VoxelModelEffect.d.ts +1 -1
  111. package/Mesher/{Models → Voxels/Models}/VoxelModelEffect.js +1 -1
  112. package/Renderer/Classes/DVESectionMeshes.d.ts +1 -1
  113. package/Renderer/MeshManager.js +1 -1
  114. package/Settings/EngineSettings.types.d.ts +2 -1
  115. package/Settings/EngineSettings.types.js +3 -1
  116. package/Tasks/Paint/Common.js +14 -9
  117. package/Tasks/Paint/Erase/EraseVoxel.js +1 -1
  118. package/Tasks/Paint/Erase/EraseVoxelSelection.d.ts +4 -0
  119. package/Tasks/Paint/Erase/EraseVoxelSelection.js +33 -0
  120. package/Tasks/Paint/Erase/EraseVoxelTemplate.js +1 -2
  121. package/Tasks/Paint/Paint/PaintVoxelTemplate.js +1 -1
  122. package/Tasks/Propagation/Illumanation/RGBUpdate.js +1 -1
  123. package/Tasks/Tasks.types.d.ts +2 -0
  124. package/Tasks/TasksIds.d.ts +1 -0
  125. package/Tasks/TasksIds.js +1 -0
  126. package/Tasks/WorldGeneration/InitTasks.js +3 -1
  127. package/Templates/Archive/ArchivedVoxelTemplate.d.ts +6 -5
  128. package/Templates/Archive/ArchivedVoxelTemplate.js +56 -49
  129. package/Templates/Archive/Functions/CreateArchivedTemplate.js +4 -4
  130. package/Templates/Archive/Functions/ExportArchiedTemplateJSON.js +0 -1
  131. package/Templates/Archive/Functions/ImportArchivedTemplateJSON.js +0 -2
  132. package/Templates/Cursor/TemplateCursor.d.ts +6 -1
  133. package/Templates/Cursor/TemplateCursor.js +16 -3
  134. package/Templates/Cursor/TemplateProxy.d.ts +1 -0
  135. package/Templates/Cursor/TemplateProxy.js +9 -0
  136. package/Templates/Cursor/TemplateVoxelCursor.d.ts +1 -0
  137. package/Templates/Cursor/TemplateVoxelCursor.js +6 -0
  138. package/Templates/Full/FullVoxelTemplate.d.ts +5 -4
  139. package/Templates/Full/FullVoxelTemplate.js +32 -17
  140. package/Templates/Functions/ExtrudeSelection.d.ts +5 -0
  141. package/Templates/Functions/ExtrudeSelection.js +44 -0
  142. package/Templates/Functions/FillSelection.d.ts +4 -0
  143. package/Templates/Functions/FillSelection.js +20 -0
  144. package/Templates/Functions/FlipTemplate.d.ts +2 -2
  145. package/Templates/Functions/FlipTemplate.js +8 -8
  146. package/Templates/Functions/RotateTemplate.d.ts +2 -2
  147. package/Templates/Path/VoxelPath.d.ts +4 -0
  148. package/Templates/Path/VoxelPath.js +18 -0
  149. package/Templates/Path/VoxelPath.types.d.ts +1 -0
  150. package/Templates/Selection/VoxelBFSSelection.d.ts +6 -6
  151. package/Templates/Selection/VoxelBFSSelection.js +29 -22
  152. package/Templates/Selection/VoxelBoundsSelection.d.ts +20 -0
  153. package/Templates/Selection/{VoxelBoxSelection.js → VoxelBoundsSelection.js} +38 -20
  154. package/Templates/Selection/VoxelPointSelection.d.ts +19 -0
  155. package/Templates/Selection/VoxelPointSelection.js +49 -0
  156. package/Templates/Selection/VoxelSelection.d.ts +18 -0
  157. package/Templates/Selection/VoxelSelection.js +1 -0
  158. package/Templates/Selection/VoxelSurfaceSelection.d.ts +8 -12
  159. package/Templates/Selection/VoxelSurfaceSelection.js +88 -84
  160. package/Templates/Selection/VoxelTemplateSelection.d.ts +13 -4
  161. package/Templates/Selection/VoxelTemplateSelection.js +27 -9
  162. package/Templates/Shapes/Selections/BoxVoxelShapeSelection.d.ts +28 -0
  163. package/Templates/Shapes/Selections/BoxVoxelShapeSelection.js +77 -0
  164. package/Templates/Shapes/Selections/ConeVoxelShapeSelection.d.ts +28 -0
  165. package/Templates/Shapes/Selections/ConeVoxelShapeSelection.js +77 -0
  166. package/Templates/Shapes/Selections/CylinderVoxelShapeSelection.d.ts +28 -0
  167. package/Templates/Shapes/Selections/CylinderVoxelShapeSelection.js +77 -0
  168. package/Templates/Shapes/Selections/EllipsoidVoxelShapeSelection.d.ts +28 -0
  169. package/Templates/Shapes/Selections/EllipsoidVoxelShapeSelection.js +92 -0
  170. package/Templates/Shapes/Selections/OctahedronVoxelShapeSelection.d.ts +28 -0
  171. package/Templates/Shapes/Selections/OctahedronVoxelShapeSelection.js +76 -0
  172. package/Templates/Shapes/Selections/PyramidVoxelShapeSelection.d.ts +37 -0
  173. package/Templates/Shapes/Selections/PyramidVoxelShapeSelection.js +137 -0
  174. package/Templates/Shapes/Selections/SphereVoxelShapeSelection.d.ts +20 -0
  175. package/Templates/Shapes/Selections/SphereVoxelShapeSelection.js +61 -0
  176. package/Templates/Shapes/Selections/TorusVoxelShapeSelection.d.ts +28 -0
  177. package/Templates/Shapes/Selections/TorusVoxelShapeSelection.js +76 -0
  178. package/Templates/Shapes/Selections/VoxelShapeSelection.d.ts +5 -0
  179. package/Templates/Shapes/Selections/VoxelShapeSelection.js +1 -0
  180. package/Templates/Shapes/VoxelShape.types.d.ts +2 -0
  181. package/Templates/Shapes/VoxelShape.types.js +8 -0
  182. package/Templates/Shapes/VoxelShapeTemplate.d.ts +37 -0
  183. package/Templates/Shapes/{BasicVoxelShapeTemplate.js → VoxelShapeTemplate.js} +43 -37
  184. package/Templates/Shapes/VoxelShapeTemplate.types.d.ts +5 -12
  185. package/Templates/Shapes/VoxelShapeTemplate.types.js +5 -1
  186. package/Templates/{VoxelTempateRegister.d.ts → VoxelTemplateRegister.d.ts} +4 -0
  187. package/Templates/VoxelTemplateRegister.js +60 -0
  188. package/Templates/VoxelTemplates.types.d.ts +3 -3
  189. package/Textures/Classes/CompiledTexture.d.ts +2 -0
  190. package/Textures/Classes/CompiledTexture.js +19 -1
  191. package/Textures/Classes/TextureAnimationTexture.d.ts +1 -1
  192. package/Textures/Functions/BuildTextureData.js +13 -0
  193. package/Textures/TextureManager.d.ts +1 -0
  194. package/Textures/TextureManager.js +11 -5
  195. package/Tools/Brush/Brush.d.ts +2 -0
  196. package/Tools/Brush/Brush.js +19 -0
  197. package/Tools/Tasks/TasksTool.d.ts +2 -1
  198. package/Tools/Tasks/TasksTool.js +2 -0
  199. package/Util/BinaryBuffer/Functions/BinaryBufferConvert.d.ts +1 -1
  200. package/Util/BinaryBuffer/Functions/BinaryBufferToTypedArray.d.ts +1 -1
  201. package/Util/LocationData.d.ts +1 -1
  202. package/Voxels/Cursor/DataCursor.interface.d.ts +4 -0
  203. package/Voxels/Cursor/VoxelCursor.interface.d.ts +2 -0
  204. package/Voxels/Cursor/VoxelCursor.interface.js +2 -0
  205. package/Voxels/Cursor/VoxelLightData.js +2 -2
  206. package/Voxels/Functions/BuildTagData.js +1 -1
  207. package/Voxels/Indexes/VoxelIndex.d.ts +1 -0
  208. package/Voxels/Indexes/VoxelIndex.js +11 -13
  209. package/Voxels/InitVoxelData.js +5 -14
  210. package/Voxels/Interaction/Functions/PickVoxel.d.ts +0 -5
  211. package/Voxels/Interaction/Functions/PickVoxel.js +64 -85
  212. package/Voxels/Interaction/Functions/PickVoxelWorld.js +21 -46
  213. package/Voxels/Interaction/VoxelPickResult.d.ts +1 -0
  214. package/Voxels/Interaction/VoxelPickResult.js +3 -0
  215. package/Voxels/Models/CompiledVoxelModel.types.d.ts +1 -1
  216. package/Voxels/Models/Defaults/CubeVoxelGeometry.js +11 -0
  217. package/Voxels/Models/Defaults/CubeVoxelModels.js +44 -99
  218. package/Voxels/Models/Defaults/PanelVoxelGeometry.d.ts +1 -3
  219. package/Voxels/Models/Defaults/PanelVoxelGeometry.js +2 -226
  220. package/Voxels/Models/Defaults/PanelVoxelModels.d.ts +1 -0
  221. package/Voxels/Models/Defaults/PanelVoxelModels.js +100 -258
  222. package/Voxels/Models/Defaults/StairVoxelModel.js +2 -2
  223. package/Voxels/Models/Rules/Classes/GeomtryInput.d.ts +4 -1
  224. package/Voxels/Models/Rules/Classes/GeomtryInput.js +26 -5
  225. package/Voxels/Models/Rules/Classes/VoxelRulesGeometry.d.ts +1 -1
  226. package/Voxels/Models/Rules/Functions/BuildFinalInputs.js +23 -8
  227. package/Voxels/Models/Rules/Functions/Compile/CompileGeomtryNodes.d.ts +1 -1
  228. package/Voxels/Models/Rules/Functions/Compile/Nodes/CompileBoxGeometryNode.d.ts +1 -1
  229. package/Voxels/Models/Rules/Functions/Compile/Nodes/CompileQuadGeometryNode.d.ts +1 -1
  230. package/Voxels/Models/Rules/Functions/Compile/Nodes/CompileQuadGeometryNode.js +1 -1
  231. package/Voxels/Models/Rules/Functions/Compile/Nodes/CompileTriangleGeometryNode.d.ts +1 -1
  232. package/Voxels/Models/Rules/Functions/Compile/Nodes/CompileTriangleGeometryNode.js +1 -1
  233. package/Voxels/Models/VoxelModel.types.d.ts +6 -1
  234. package/Voxels/State/Schema/BinarySchemaNode.d.ts +2 -1
  235. package/Voxels/State/Schema/BinarySchemaNode.js +5 -2
  236. package/Voxels/State/Schema/Conditions/SameVoxelConditions.js +2 -0
  237. package/Voxels/Types/PaintVoxelData.d.ts +13 -1
  238. package/Voxels/Types/PaintVoxelData.js +151 -14
  239. package/World/Archive/Functions/Shared/LightSegments.d.ts +1 -1
  240. package/World/Cursor/SectionCursor.d.ts +4 -0
  241. package/World/Cursor/SectionCursor.js +13 -16
  242. package/World/Cursor/SectorCursor.d.ts +4 -0
  243. package/World/Cursor/SectorCursor.js +13 -16
  244. package/World/Cursor/WorldCursor.d.ts +4 -0
  245. package/World/Cursor/WorldCursor.js +8 -0
  246. package/World/Sector/Sector.d.ts +1 -1
  247. package/World/Sector/SectorHeightMap.d.ts +6 -0
  248. package/World/Sector/SectorHeightMap.js +6 -0
  249. package/World/SnapShot/SectionSnapShotCursor.d.ts +3 -0
  250. package/World/SnapShot/SectionSnapShotCursor.js +6 -0
  251. package/World/WorldSpaces.js +3 -3
  252. package/WorldSimulation/Dimensions/DimensionSimulation.d.ts +5 -1
  253. package/WorldSimulation/Dimensions/DimensionSimulation.js +12 -0
  254. package/WorldSimulation/Dimensions/Generator.d.ts +1 -0
  255. package/WorldSimulation/Dimensions/Generator.js +1 -0
  256. package/WorldSimulation/Dimensions/SimulationSector.d.ts +4 -1
  257. package/WorldSimulation/Dimensions/SimulationSector.js +71 -41
  258. package/WorldSimulation/Internal/WorldSimulationTasks.js +5 -2
  259. package/WorldSimulation/Procedures/BuildOnly.d.ts +10 -0
  260. package/WorldSimulation/Procedures/BuildOnly.js +55 -0
  261. package/WorldSimulation/Procedures/InitalLoad.js +3 -0
  262. package/WorldSimulation/Tasks/SimulationTaskBase.d.ts +2 -0
  263. package/WorldSimulation/Tasks/SimulationTaskBase.js +11 -3
  264. package/WorldSimulation/Tasks/TaskSegment.d.ts +2 -1
  265. package/WorldSimulation/Tasks/TaskSegment.js +3 -1
  266. package/WorldSimulation/Tick/TickQueue.d.ts +2 -0
  267. package/WorldSimulation/Tick/TickQueue.js +26 -0
  268. package/WorldSimulation/Tools/SimulationBrush.d.ts +3 -0
  269. package/WorldSimulation/Tools/SimulationBrush.js +52 -0
  270. package/WorldSimulation/Voxels/Behaviors/Types/DefaultVoxelBehavior.js +3 -0
  271. package/WorldSimulation/Voxels/Behaviors/Types/LiquidVoxelBehavior.js +21 -1
  272. package/WorldSimulation/Voxels/Behaviors/VoxelBehaviors.d.ts +2 -0
  273. package/WorldSimulation/Voxels/Behaviors/VoxelBehaviors.js +6 -0
  274. package/WorldSimulation/Voxels/Ticks/Types/LiquidVoxelUpdate.js +39 -14
  275. package/WorldSimulation/WorldSimulation.d.ts +10 -0
  276. package/WorldSimulation/WorldSimulation.js +41 -1
  277. package/package.json +1 -30
  278. package/Mesher/Functions/CompactVoxelMesh.d.ts +0 -3
  279. package/Mesher/Functions/MeshTexture.js +0 -278
  280. package/Mesher/Geomtry/VoxelMesh.d.ts +0 -12
  281. package/Mesher/Geomtry/VoxelMesh.js +0 -25
  282. package/Mesher/Models/Procedures/Default/ConsistentRotationTextureProcedure.d.ts +0 -25
  283. package/Mesher/Models/Procedures/Default/OutlinedTextureProcedure.js +0 -162
  284. package/Templates/Selection/VoxelBoxSelection.d.ts +0 -14
  285. package/Templates/Selection/VoxelSelecton.d.ts +0 -6
  286. package/Templates/Shapes/BasicVoxelShapeTemplate.d.ts +0 -35
  287. package/Templates/Shapes/BoxVoxelTemplate.d.ts +0 -22
  288. package/Templates/Shapes/BoxVoxelTemplate.js +0 -75
  289. package/Templates/Shapes/ConeVoxelTemplate.d.ts +0 -22
  290. package/Templates/Shapes/ConeVoxelTemplate.js +0 -69
  291. package/Templates/Shapes/CylinderVoxelTemplate.d.ts +0 -22
  292. package/Templates/Shapes/CylinderVoxelTemplate.js +0 -69
  293. package/Templates/Shapes/OctahedronVoxelTemplate.d.ts +0 -22
  294. package/Templates/Shapes/OctahedronVoxelTemplate.js +0 -69
  295. package/Templates/Shapes/PyramidVoxelTemplate.d.ts +0 -30
  296. package/Templates/Shapes/PyramidVoxelTemplate.js +0 -140
  297. package/Templates/Shapes/SphereVoxelTemplate.d.ts +0 -24
  298. package/Templates/Shapes/SphereVoxelTemplate.js +0 -97
  299. package/Templates/Shapes/TorusVoxelTemplate.d.ts +0 -22
  300. package/Templates/Shapes/TorusVoxelTemplate.js +0 -69
  301. package/Templates/VoxelTempateRegister.js +0 -30
  302. /package/{Mesher/Models/Nodes/Types/GeomtryNode.types.js → Builder/RayProvider.js} +0 -0
  303. /package/Mesher/{Functions/MeshTexture.d.ts → Items/MeshTextureO.d.ts} +0 -0
  304. /package/Mesher/{Functions → Voxels/Base}/CompactVoxelSectionMesh.js +0 -0
  305. /package/Mesher/{Geomtry → Voxels/Geomtry}/VoxelMeshBVHStructCursor.d.ts +0 -0
  306. /package/Mesher/{Geomtry → Voxels/Geomtry}/VoxelMeshBVHStructCursor.js +0 -0
  307. /package/Mesher/{Geomtry → Voxels/Geomtry}/VoxelMeshVertexStructCursor.d.ts +0 -0
  308. /package/Mesher/{Geomtry → Voxels/Geomtry}/VoxelMeshVertexStructCursor.js +0 -0
  309. /package/Mesher/{Geomtry → Voxels/Geomtry}/VoxelShaderData.d.ts +0 -0
  310. /package/Mesher/{Geomtry → Voxels/Geomtry}/VoxelShaderData.js +0 -0
  311. /package/Mesher/{Functions → Voxels}/MeshSection.d.ts +0 -0
  312. /package/Mesher/{Functions → Voxels}/MeshSection.js +0 -0
  313. /package/Mesher/{Functions → Voxels}/MeshSectionSnapShot.d.ts +0 -0
  314. /package/Mesher/{Functions → Voxels}/MeshSectionSnapShot.js +0 -0
  315. /package/Mesher/{Models → Voxels/Models}/Common/Faces/CullRulledFace.d.ts +0 -0
  316. /package/Mesher/{Models → Voxels/Models}/Common/Faces/ShadeRulelessFace.js +0 -0
  317. /package/Mesher/{Models → Voxels/Models}/Common/GetTexture.js +0 -0
  318. /package/Mesher/{Models → Voxels/Models}/Nodes/Custom/index.d.ts +0 -0
  319. /package/Mesher/{Models → Voxels/Models}/Nodes/Custom/index.js +0 -0
  320. /package/Mesher/{Models → Voxels/Models}/Nodes/GeometryNode.d.ts +0 -0
  321. /package/Mesher/{Models → Voxels/Models}/Nodes/GeometryNode.js +0 -0
  322. /package/Mesher/{Models → Voxels/Models}/Nodes/Types/GeomtryNode.types.d.ts +0 -0
  323. /package/{Templates/Selection/VoxelSelecton.js → Mesher/Voxels/Models/Nodes/Types/GeomtryNode.types.js} +0 -0
  324. /package/Mesher/{Models → Voxels/Models}/Nodes/Types/QuadVoxelGometryNodeTypes.js +0 -0
  325. /package/Mesher/{Models → Voxels/Models}/Nodes/Types/TriangleVoxelGometryNodeTypes.js +0 -0
  326. /package/Mesher/{Models → Voxels/Models}/Nodes/VoxelGeometryConstructor.js +0 -0
  327. /package/Mesher/{Models → Voxels/Models}/Procedures/TextureProcedure.js +0 -0
  328. /package/Mesher/{Models → Voxels/Models}/Procedures/TextureProcedureRegister.d.ts +0 -0
  329. /package/Mesher/{Models → Voxels/Models}/RenderedMaterials.d.ts +0 -0
  330. /package/Mesher/{Models → Voxels/Models}/RenderedMaterials.js +0 -0
@@ -0,0 +1,184 @@
1
+ import { PaintVoxelData } from "../../../Voxels";
2
+ import { VoxelPointSelection } from "../../../Templates/Selection/VoxelPointSelection";
3
+ import { BuilderToolBase } from "../BuilderToolBase";
4
+ import { SchemaRegister } from "../../../Voxels/State/SchemaRegister";
5
+ import { VoxelPalettesRegister } from "../../../Voxels/Data/VoxelPalettesRegister";
6
+ var WrenchToolModes;
7
+ (function (WrenchToolModes) {
8
+ WrenchToolModes["Pick"] = "Pick";
9
+ WrenchToolModes["Update"] = "Update";
10
+ })(WrenchToolModes || (WrenchToolModes = {}));
11
+ export class WrenchTool extends BuilderToolBase {
12
+ static ToolId = "Wrench";
13
+ mode = WrenchToolModes.Pick;
14
+ selection = new VoxelPointSelection();
15
+ paintData = PaintVoxelData.Create();
16
+ _pickedResult = null;
17
+ isUpdating() {
18
+ if (this._pickedResult !== null && this.mode == WrenchToolModes.Update)
19
+ return true;
20
+ return false;
21
+ }
22
+ stopUpdating() {
23
+ this.mode = WrenchToolModes.Pick;
24
+ this._pickedResult = null;
25
+ }
26
+ async update() {
27
+ this._lastPicked = await this.space.pickWithProvider(this.rayProviderIndex);
28
+ if (!this._lastPicked)
29
+ return;
30
+ if (this.mode == WrenchToolModes.Pick) {
31
+ if (!this.space.bounds.intersectsPoint(this._lastPicked.position)) {
32
+ this._lastPicked = null;
33
+ return;
34
+ }
35
+ this.selection.reConstruct(this._lastPicked.position);
36
+ }
37
+ }
38
+ processSchema(schema) {
39
+ const nodes = [];
40
+ for (const node of schema.nodes) {
41
+ if (node.valuePalette) {
42
+ nodes.push({
43
+ id: node.name,
44
+ label: node.name,
45
+ values: [...node.valuePalette._palette],
46
+ type: "string",
47
+ value: "",
48
+ });
49
+ }
50
+ else {
51
+ nodes.push({
52
+ id: node.name,
53
+ label: node.name,
54
+ min: 0,
55
+ max: Math.pow(2, node.data.bitSize) - 1,
56
+ type: "number",
57
+ value: 0,
58
+ });
59
+ }
60
+ }
61
+ return nodes;
62
+ }
63
+ updatePickedSchema(schema) {
64
+ if (!this._pickedResult)
65
+ return;
66
+ const trueVoxelId = this._pickedResult.voxel.getVoxelId();
67
+ const voxelSchemas = SchemaRegister.getVoxelSchemas(this._pickedResult.voxel.getStringId());
68
+ voxelSchemas.state.startEncoding(this._pickedResult.voxel.getState());
69
+ voxelSchemas.mod.startEncoding(this._pickedResult.voxel.getMod());
70
+ for (const node of schema.stateSchema) {
71
+ if (node.type == "string") {
72
+ voxelSchemas.state.setValue(node.id, node.value);
73
+ }
74
+ else {
75
+ voxelSchemas.state.setNumber(node.id, node.value);
76
+ }
77
+ }
78
+ for (const node of schema.modSchema) {
79
+ if (node.type == "string") {
80
+ voxelSchemas.mod.setValue(node.id, node.value);
81
+ }
82
+ else {
83
+ voxelSchemas.mod.setNumber(node.id, node.value);
84
+ }
85
+ }
86
+ const currentRaw = this._pickedResult.voxel.getRaw();
87
+ const rawVoxelData = [
88
+ VoxelPalettesRegister.getVoxelId(trueVoxelId, voxelSchemas.state.getEncoded(), voxelSchemas.mod.getEncoded()),
89
+ currentRaw[1],
90
+ currentRaw[2],
91
+ currentRaw[3],
92
+ ];
93
+ this.paintData = PaintVoxelData.FromRaw(rawVoxelData);
94
+ return this.paintData;
95
+ }
96
+ getPickedSchema() {
97
+ if (!this._pickedResult)
98
+ return null;
99
+ const id = this._pickedResult.voxel.getStringId();
100
+ const voxelSchemas = SchemaRegister.getVoxelSchemas(id);
101
+ voxelSchemas.state.startEncoding(this._pickedResult.voxel.getState());
102
+ voxelSchemas.mod.startEncoding(this._pickedResult.voxel.getMod());
103
+ return {
104
+ stateSchema: this.processSchema(voxelSchemas.state),
105
+ modSchema: this.processSchema(voxelSchemas.mod),
106
+ };
107
+ }
108
+ /**Get an array of all possible state varations for the current mod of the selected voxel. */
109
+ getStateValues() {
110
+ if (!this._pickedResult)
111
+ return null;
112
+ const voxelStates = [];
113
+ const voxelId = this._pickedResult.voxel.id;
114
+ const [trueId, , mod] = VoxelPalettesRegister.voxels[voxelId];
115
+ const stateArray = VoxelPalettesRegister.voxelRecord[trueId][mod];
116
+ const rawVoxelData = [0, 0, 0, 0];
117
+ for (let i = 0; i < stateArray.length; i++) {
118
+ const value = stateArray[i];
119
+ if (value === undefined || value <= 0)
120
+ continue;
121
+ rawVoxelData[0] = value;
122
+ voxelStates.push(PaintVoxelData.FromRaw(rawVoxelData));
123
+ }
124
+ return voxelStates;
125
+ }
126
+ /**Get an array of all possible mod varations for the current state of the selected voxel. */
127
+ getModValues() {
128
+ if (!this._pickedResult)
129
+ return null;
130
+ const voxelStates = [];
131
+ const voxelId = this._pickedResult.voxel.id;
132
+ const [trueId, state] = VoxelPalettesRegister.voxels[voxelId];
133
+ const modArray = VoxelPalettesRegister.voxelRecord[trueId];
134
+ const rawVoxelData = [0, 0, 0, 0];
135
+ for (let i = 0; i < modArray.length; i++) {
136
+ const stateArray = modArray[i];
137
+ if (stateArray === undefined || !stateArray.length)
138
+ continue;
139
+ let id = -1;
140
+ for (let j = 0; j < stateArray.length; j++) {
141
+ id = VoxelPalettesRegister.voxelRecord[trueId][i][state];
142
+ if (id === undefined || id < 0)
143
+ continue;
144
+ rawVoxelData[0] = id;
145
+ break;
146
+ }
147
+ if (id === undefined || id < 0)
148
+ continue;
149
+ voxelStates.push(PaintVoxelData.FromRaw(rawVoxelData));
150
+ }
151
+ return voxelStates;
152
+ }
153
+ cancel() {
154
+ this._lastPicked = null;
155
+ }
156
+ async use() {
157
+ if (this.mode == WrenchToolModes.Pick) {
158
+ if (this._lastPicked && !this._lastPicked.voxel.isAir()) {
159
+ this._pickedResult = this._lastPicked.clone();
160
+ this.dispatch("picked", {});
161
+ this.mode = WrenchToolModes.Update;
162
+ return;
163
+ }
164
+ else {
165
+ this._pickedResult = null;
166
+ }
167
+ }
168
+ if (this.mode == WrenchToolModes.Update) {
169
+ await this.space.paintVoxel([
170
+ this.selection.origin.x,
171
+ this.selection.origin.y,
172
+ this.selection.origin.z,
173
+ ], this.paintData);
174
+ return;
175
+ }
176
+ }
177
+ getOptionValue(id) {
178
+ return null;
179
+ }
180
+ getCurrentOptions() {
181
+ return [];
182
+ }
183
+ updateOption(property, value) { }
184
+ }
@@ -0,0 +1,12 @@
1
+ import { VoxelBuildSpace } from "../VoxelBuildSpace";
2
+ import { VoxelBoundsSelection } from "../../Templates/Selection/VoxelBoundsSelection";
3
+ import { Vector3Like } from "@amodx/math";
4
+ import { FreePointSelection } from "./FreePointSelection";
5
+ export declare class FreeBoxSelection {
6
+ space: VoxelBuildSpace;
7
+ point: FreePointSelection;
8
+ start: Vector3Like;
9
+ selection: VoxelBoundsSelection;
10
+ constructor(space: VoxelBuildSpace, point: FreePointSelection);
11
+ update(): void;
12
+ }
@@ -0,0 +1,21 @@
1
+ import { VoxelBoundsSelection } from "../../Templates/Selection/VoxelBoundsSelection";
2
+ import { Axes } from "@amodx/math/Vectors/Axes";
3
+ export class FreeBoxSelection {
4
+ space;
5
+ point;
6
+ start;
7
+ selection;
8
+ constructor(space, point) {
9
+ this.space = space;
10
+ this.point = point;
11
+ this.start = { ...point.selection.origin };
12
+ this.selection = new VoxelBoundsSelection();
13
+ this.selection.reConstruct(this.start, Axes.UpReadOnly(), this.start, Axes.UpReadOnly());
14
+ }
15
+ update() {
16
+ const point = this.point.getPoint();
17
+ if (!point)
18
+ return;
19
+ this.selection.reConstruct(this.start, Axes.UpReadOnly(), point, Axes.UpReadOnly());
20
+ }
21
+ }
@@ -0,0 +1,14 @@
1
+ import { VoxelBuildSpace } from "../VoxelBuildSpace";
2
+ import { Vector3Like } from "@amodx/math";
3
+ import { VoxelPointSelection } from "../../Templates/Selection/VoxelPointSelection";
4
+ export declare class FreePointSelection {
5
+ space: VoxelBuildSpace;
6
+ selection: VoxelPointSelection;
7
+ distance: number;
8
+ planeOrigin: Vector3Like;
9
+ planeNormal: Vector3Like;
10
+ offset: number;
11
+ constructor(space: VoxelBuildSpace, selection: VoxelPointSelection, distance?: number);
12
+ getPoint(): Vector3Like | undefined;
13
+ update(): boolean;
14
+ }
@@ -0,0 +1,39 @@
1
+ import { Vector3Like } from "@amodx/math";
2
+ export class FreePointSelection {
3
+ space;
4
+ selection;
5
+ distance;
6
+ planeOrigin = Vector3Like.Create();
7
+ planeNormal = Vector3Like.Create();
8
+ offset = 0;
9
+ constructor(space, selection, distance = 10) {
10
+ this.space = space;
11
+ this.selection = selection;
12
+ this.distance = distance;
13
+ }
14
+ getPoint() {
15
+ let rayPosition = Vector3Like.FloorInPlace(Vector3Like.Add(this.space.rayProvider.origin, Vector3Like.MultiplyScalar(this.space.rayProvider.direction, this.distance)));
16
+ if (!this.space.bounds.intersectsPoint(rayPosition)) {
17
+ const rayIntersection = this.space.bounds.rayIntersection(this.space.rayProvider.origin, this.space.rayProvider.direction, this.space.rayProvider.length);
18
+ if (!isFinite(rayIntersection))
19
+ return;
20
+ if (rayIntersection == 0) {
21
+ const rayIntersectionFromWithin = this.space.bounds.rayIntersectionFromWithin(this.space.rayProvider.origin, this.space.rayProvider.direction, this.space.rayProvider.length);
22
+ if (!isFinite(rayIntersectionFromWithin))
23
+ return;
24
+ rayPosition = Vector3Like.FloorInPlace(Vector3Like.Add(this.space.rayProvider.origin, Vector3Like.MultiplyScalar(this.space.rayProvider.direction, rayIntersectionFromWithin)));
25
+ }
26
+ else {
27
+ rayPosition = Vector3Like.FloorInPlace(Vector3Like.Add(this.space.rayProvider.origin, Vector3Like.MultiplyScalar(this.space.rayProvider.direction, rayIntersection)));
28
+ }
29
+ }
30
+ return rayPosition;
31
+ }
32
+ update() {
33
+ const point = this.getPoint();
34
+ if (!point)
35
+ return false;
36
+ this.selection.reConstruct(point);
37
+ return true;
38
+ }
39
+ }
@@ -0,0 +1,12 @@
1
+ import { VoxelBuildSpace } from "../VoxelBuildSpace";
2
+ import { VoxelBoundsSelection } from "../../Templates/Selection/VoxelBoundsSelection";
3
+ import { Vector3Like } from "@amodx/math";
4
+ export declare class SurfaceBoxSelection {
5
+ space: VoxelBuildSpace;
6
+ selection: VoxelBoundsSelection;
7
+ planeOrigin: Vector3Like;
8
+ planeNormal: Vector3Like;
9
+ offset: number;
10
+ constructor(space: VoxelBuildSpace, selection: VoxelBoundsSelection);
11
+ update(): void;
12
+ }
@@ -0,0 +1,25 @@
1
+ import { Vector3Like } from "@amodx/math";
2
+ export class SurfaceBoxSelection {
3
+ space;
4
+ selection;
5
+ planeOrigin = Vector3Like.Create();
6
+ planeNormal = Vector3Like.Create();
7
+ offset = 0;
8
+ constructor(space, selection) {
9
+ this.space = space;
10
+ this.selection = selection;
11
+ }
12
+ update() {
13
+ const rayOrigin = this.space.rayProvider.origin;
14
+ const rayDirection = this.space.rayProvider.direction;
15
+ const distance = Vector3Like.Dot(Vector3Like.Subtract(this.planeOrigin, rayOrigin), this.planeNormal) / Vector3Like.Dot(rayDirection, this.planeNormal);
16
+ const intersectionPoint = Vector3Like.FloorInPlace(Vector3Like.Add(rayOrigin, Vector3Like.MultiplyScalar(rayDirection, distance)));
17
+ let offset = this.offset;
18
+ if (this.planeNormal.x > 0 ||
19
+ this.planeNormal.y > 0 ||
20
+ this.planeNormal.z > 0) {
21
+ offset++;
22
+ }
23
+ this.selection.reConstruct(this.planeOrigin, this.planeNormal, intersectionPoint, this.planeNormal, offset);
24
+ }
25
+ }
@@ -0,0 +1,73 @@
1
+ import { Vec3Array, Vector3Like } from "@amodx/math";
2
+ import { BoundingBox } from "@amodx/math/Geomtry/Bounds/BoundingBox";
3
+ import { DivineVoxelEngineRender } from "../Contexts/Render";
4
+ import { VoxelPathData } from "../Templates/Path/VoxelPath.types";
5
+ import { IVoxelTemplateData } from "../Templates/VoxelTemplates.types";
6
+ import { PaintVoxelData } from "../Voxels";
7
+ import { VoxelPickResult } from "../Voxels/Interaction/VoxelPickResult";
8
+ import { RayProvider } from "./RayProvider";
9
+ import { FullVoxelTemplate } from "../Templates/Full/FullVoxelTemplate";
10
+ import { BoundsMinMaxData } from "@amodx/math/Geomtry/Bounds/BoundsInterface";
11
+ import type { VoxelSurfaceSelectionData } from "../Templates/Selection/VoxelSurfaceSelection";
12
+ import type { VoxelBFSSelectionData } from "../Templates/Selection/VoxelBFSSelection";
13
+ import { IVoxelSelectionData } from "../Templates/Selection/VoxelSelection";
14
+ import "../Templates/VoxelTemplateRegister";
15
+ type VoxelSpaceBaseUpdateData<Type extends string, Data extends any> = {
16
+ type: Type;
17
+ remote?: true;
18
+ } & Data;
19
+ export type VoxelSpaceUpdateData = VoxelSpaceBaseUpdateData<"paint-voxel", {
20
+ position: Vec3Array;
21
+ voxel: PaintVoxelData;
22
+ }> | VoxelSpaceBaseUpdateData<"erase-voxel", {
23
+ position: Vec3Array;
24
+ }> | VoxelSpaceBaseUpdateData<"paint-voxel-template", {
25
+ position: Vec3Array;
26
+ template: IVoxelTemplateData<any>;
27
+ }> | VoxelSpaceBaseUpdateData<"erase-voxel-template", {
28
+ position: Vec3Array;
29
+ template: IVoxelTemplateData<any>;
30
+ }> | VoxelSpaceBaseUpdateData<"erase-voxel-selection", {
31
+ selection: IVoxelSelectionData<any>;
32
+ }> | VoxelSpaceBaseUpdateData<"paint-voxel-path", {
33
+ position: Vec3Array;
34
+ path: VoxelPathData;
35
+ }> | VoxelSpaceBaseUpdateData<"erase-voxel-path", {
36
+ position: Vec3Array;
37
+ path: VoxelPathData;
38
+ }>;
39
+ export declare class VoxelBuildSpace {
40
+ DVER: DivineVoxelEngineRender;
41
+ /**Callback that is called before the update is ran. */
42
+ beforeUpdate: ((data: VoxelSpaceUpdateData) => Promise<void> | void) | null;
43
+ /**Callback that is called durning the update call using Promise.all. */
44
+ duringUpdate: ((data: VoxelSpaceUpdateData) => Promise<void> | void) | null;
45
+ /**Callback that is called after the update is ran. */
46
+ afterUpdate: ((data: VoxelSpaceUpdateData) => Promise<void> | void) | null;
47
+ bounds: BoundingBox;
48
+ private _rayProviders;
49
+ get rayProvider(): RayProvider;
50
+ constructor(DVER: DivineVoxelEngineRender, rayProvider: RayProvider, min?: Vector3Like, max?: Vector3Like);
51
+ addRayProvider(index: number, provider: RayProvider): void;
52
+ getRayProvider(index: number): RayProvider | null;
53
+ removeRayProvider(index: number): void;
54
+ /**Pick the current voxel space. Defaults to the rayProvider values. */
55
+ pick(rayOrigin?: Vector3Like, rayDirection?: Vector3Like, length?: number): Promise<VoxelPickResult | null>;
56
+ pickWithProvider(index: number): Promise<VoxelPickResult | null>;
57
+ createTemplate(bounds: BoundsMinMaxData): Promise<FullVoxelTemplate>;
58
+ getSurfaceSelection(position: Vector3Like, normal: Vector3Like, extrusion: number, maxSize?: number): Promise<VoxelSurfaceSelectionData>;
59
+ getBFSSelection(position: Vector3Like, maxSize?: number): Promise<VoxelBFSSelectionData>;
60
+ getExtrudedSelectionTemplate(selection: IVoxelSelectionData<any>, nomral: Vector3Like): Promise<FullVoxelTemplate>;
61
+ getPlaceState(data: PaintVoxelData, picked: VoxelPickResult, alt?: number | null): PaintVoxelData | undefined;
62
+ clear(): Promise<boolean>;
63
+ private _updateFunctions;
64
+ update<T extends VoxelSpaceUpdateData>(data: T): Promise<void>;
65
+ paintVoxel(position: Vec3Array | Vector3Like, voxel: PaintVoxelData): Promise<void>;
66
+ eraseVoxel(position: Vec3Array | Vector3Like): Promise<void>;
67
+ paintTemplate(position: Vec3Array | Vector3Like | Vector3Like, template: IVoxelTemplateData<any>): Promise<void>;
68
+ eraseTemplate(position: Vec3Array | Vector3Like, template: IVoxelTemplateData<any>): Promise<void>;
69
+ eraseSelection(selection: IVoxelSelectionData<any>): Promise<void>;
70
+ paintPath(position: Vec3Array | Vector3Like, path: VoxelPathData): Promise<void>;
71
+ erasePath(position: Vec3Array | Vector3Like, path: VoxelPathData): Promise<void>;
72
+ }
73
+ export {};
@@ -0,0 +1,224 @@
1
+ import { Vector3Like } from "@amodx/math";
2
+ import { BoundingBox } from "@amodx/math/Geomtry/Bounds/BoundingBox";
3
+ import { PaintVoxelData } from "../Voxels";
4
+ import { VoxelPlacingStrategyRegister } from "../Voxels/Interaction/Placing/VoxelPlacingStrategyRegister";
5
+ import { VoxelPickResult } from "../Voxels/Interaction/VoxelPickResult";
6
+ import { SchemaRegister } from "../Voxels/State/SchemaRegister";
7
+ import { FullVoxelTemplate } from "../Templates/Full/FullVoxelTemplate";
8
+ import { VoxelShapeTemplate } from "../Templates/Shapes/VoxelShapeTemplate";
9
+ import { BoxVoxelShapeSelection } from "../Templates/Shapes/Selections/BoxVoxelShapeSelection";
10
+ import "../Templates/VoxelTemplateRegister";
11
+ export class VoxelBuildSpace {
12
+ DVER;
13
+ /**Callback that is called before the update is ran. */
14
+ beforeUpdate = null;
15
+ /**Callback that is called durning the update call using Promise.all. */
16
+ duringUpdate = null;
17
+ /**Callback that is called after the update is ran. */
18
+ afterUpdate = null;
19
+ bounds;
20
+ _rayProviders = [];
21
+ get rayProvider() {
22
+ return this.getRayProvider(0);
23
+ }
24
+ constructor(DVER, rayProvider, min = Vector3Like.Create(-Infinity, -Infinity, -Infinity), max = Vector3Like.Create(Infinity, Infinity, Infinity)) {
25
+ this.DVER = DVER;
26
+ this.bounds = new BoundingBox(min, max);
27
+ this.addRayProvider(0, rayProvider);
28
+ }
29
+ addRayProvider(index, provider) {
30
+ this._rayProviders[index] = provider;
31
+ }
32
+ getRayProvider(index) {
33
+ return this._rayProviders[index];
34
+ }
35
+ removeRayProvider(index) {
36
+ this._rayProviders[index] = null;
37
+ }
38
+ /**Pick the current voxel space. Defaults to the rayProvider values. */
39
+ async pick(rayOrigin = this.rayProvider.origin, rayDirection = this.rayProvider.direction, length = this.rayProvider.length) {
40
+ const pickedVoxel = await this.DVER.threads.world.runTaskAsync("pick-voxel", [
41
+ [rayOrigin.x, rayOrigin.y, rayOrigin.z],
42
+ [rayDirection.x, rayDirection.y, rayDirection.z],
43
+ length,
44
+ ]);
45
+ if (pickedVoxel === null) {
46
+ return null;
47
+ }
48
+ return VoxelPickResult.FromJSON(pickedVoxel);
49
+ }
50
+ async pickWithProvider(index) {
51
+ const provider = this.getRayProvider(index);
52
+ if (!provider) {
53
+ throw new Error(`Ray Provider at index ${index} is not set`);
54
+ }
55
+ return await this.pick(provider.origin, this.rayProvider.direction, this.rayProvider.length);
56
+ }
57
+ async createTemplate(bounds) {
58
+ const templateData = await this.DVER.threads.world.runTaskAsync("create-voxel-template", [
59
+ [0, ...Vector3Like.ToArray(bounds.min)],
60
+ bounds,
61
+ ]);
62
+ return new FullVoxelTemplate(templateData);
63
+ }
64
+ async getSurfaceSelection(position, normal, extrusion, maxSize) {
65
+ return await this.DVER.threads.world.runTaskAsync("get-voxel-surface-selection", [position, normal, extrusion, maxSize]);
66
+ }
67
+ async getBFSSelection(position, maxSize) {
68
+ return await this.DVER.threads.world.runTaskAsync("get-voxel-bfs-selection", [position, maxSize]);
69
+ }
70
+ async getExtrudedSelectionTemplate(selection, nomral) {
71
+ const templateData = await this.DVER.threads.world.runTaskAsync("get-extruded-voxel-selection-template", [selection, nomral]);
72
+ return new FullVoxelTemplate(templateData);
73
+ }
74
+ getPlaceState(data, picked, alt = null) {
75
+ const strategy = VoxelPlacingStrategyRegister.get(data.id);
76
+ if (!strategy)
77
+ return data;
78
+ const state = strategy.getState(picked, alt);
79
+ if (!state) {
80
+ data.state = 0;
81
+ return data;
82
+ }
83
+ const schema = SchemaRegister.getVoxelSchemas(data.id);
84
+ data.state = schema.state.readString(state);
85
+ }
86
+ async clear() {
87
+ const size = this.bounds.size;
88
+ if (!isFinite(size.x) || !isFinite(size.y) || !isFinite(size.z))
89
+ return false;
90
+ const min = this.bounds.min;
91
+ await this.DVER.threads.world.runTaskAsync("erase-voxel-template", [
92
+ [0, min.x, min.y, min.z],
93
+ VoxelShapeTemplate.CreateNew({
94
+ shapeSelection: BoxVoxelShapeSelection.CreateNew({
95
+ width: this.bounds.size.x,
96
+ height: this.bounds.size.y,
97
+ depth: this.bounds.size.z,
98
+ }),
99
+ }),
100
+ ]);
101
+ return true;
102
+ }
103
+ _updateFunctions = {
104
+ "paint-voxel": async (update) => {
105
+ await this.DVER.threads.world.runTaskAsync("paint-voxel", [
106
+ [0, ...update.position],
107
+ PaintVoxelData.ToRaw(update.voxel),
108
+ ]);
109
+ },
110
+ "erase-voxel": async (update) => {
111
+ await this.DVER.threads.world.runTaskAsync("erase-voxel", [
112
+ 0,
113
+ ...update.position,
114
+ ]);
115
+ },
116
+ "paint-voxel-template": async (update) => {
117
+ await this.DVER.threads.world.runTaskAsync("paint-voxel-template", [
118
+ [0, ...update.position],
119
+ update.template,
120
+ ]);
121
+ },
122
+ "erase-voxel-template": async (update) => {
123
+ await this.DVER.threads.world.runTaskAsync("erase-voxel-template", [
124
+ [0, ...update.position],
125
+ update.template,
126
+ ]);
127
+ },
128
+ "erase-voxel-selection": async (update) => {
129
+ await this.DVER.threads.world.runTaskAsync("erase-voxel-selection", [
130
+ [
131
+ 0,
132
+ update.selection.origin.x,
133
+ update.selection.origin.y,
134
+ update.selection.origin.z,
135
+ ],
136
+ update.selection,
137
+ ]);
138
+ },
139
+ "paint-voxel-path": async (update) => {
140
+ await this.DVER.threads.world.runTaskAsync("paint-voxel-path", [
141
+ [0, ...update.position],
142
+ update.path,
143
+ ]);
144
+ },
145
+ "erase-voxel-path": async (update) => {
146
+ await this.DVER.threads.world.runTaskAsync("erase-voxel-path", [
147
+ [0, ...update.position],
148
+ update.path,
149
+ ]);
150
+ },
151
+ };
152
+ async update(data) {
153
+ if (this.beforeUpdate)
154
+ await this.beforeUpdate(data);
155
+ const run = this._updateFunctions[data.type];
156
+ if (this.duringUpdate) {
157
+ await Promise.all([run(data), this.duringUpdate(data)]);
158
+ }
159
+ else {
160
+ await run(data);
161
+ }
162
+ if (this.afterUpdate)
163
+ await this.afterUpdate(data);
164
+ }
165
+ async paintVoxel(position, voxel) {
166
+ await this.update({
167
+ type: "paint-voxel",
168
+ position: Array.isArray(position)
169
+ ? position
170
+ : Vector3Like.ToArray(position),
171
+ voxel,
172
+ });
173
+ }
174
+ async eraseVoxel(position) {
175
+ await this.update({
176
+ type: "erase-voxel",
177
+ position: Array.isArray(position)
178
+ ? position
179
+ : Vector3Like.ToArray(position),
180
+ });
181
+ }
182
+ async paintTemplate(position, template) {
183
+ await this.update({
184
+ type: "paint-voxel-template",
185
+ position: Array.isArray(position)
186
+ ? position
187
+ : Vector3Like.ToArray(position),
188
+ template,
189
+ });
190
+ }
191
+ async eraseTemplate(position, template) {
192
+ await this.update({
193
+ type: "erase-voxel-template",
194
+ position: Array.isArray(position)
195
+ ? position
196
+ : Vector3Like.ToArray(position),
197
+ template,
198
+ });
199
+ }
200
+ async eraseSelection(selection) {
201
+ await this.update({
202
+ type: "erase-voxel-selection",
203
+ selection,
204
+ });
205
+ }
206
+ async paintPath(position, path) {
207
+ await this.update({
208
+ type: "paint-voxel-path",
209
+ position: Array.isArray(position)
210
+ ? position
211
+ : Vector3Like.ToArray(position),
212
+ path,
213
+ });
214
+ }
215
+ async erasePath(position, path) {
216
+ await this.update({
217
+ type: "erase-voxel-path",
218
+ position: Array.isArray(position)
219
+ ? position
220
+ : Vector3Like.ToArray(position),
221
+ path,
222
+ });
223
+ }
224
+ }
@@ -0,0 +1 @@
1
+ export declare function InitTasks(): void;