@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
@@ -2,6 +2,7 @@ import { Flat3DIndex, Vector3Like } from "@amodx/math";
2
2
  import { getBitArrayIndex } from "../../Util/Binary/BinaryArrays";
3
3
  import { EngineSettings } from "../../Settings/EngineSettings";
4
4
  import { BoundingBox } from "@amodx/math/Geomtry/Bounds/BoundingBox";
5
+ const point = Vector3Like.Create();
5
6
  export class FullVoxelTemplate {
6
7
  static CreateNew(bounds, baseLightValue = 0) {
7
8
  const voxelSize = bounds[0] * bounds[1] * bounds[2];
@@ -29,7 +30,6 @@ export class FullVoxelTemplate {
29
30
  bufferStart += voxelSize;
30
31
  return {
31
32
  type: "full",
32
- position: Vector3Like.Create(),
33
33
  bounds: Vector3Like.Create(...bounds),
34
34
  ids,
35
35
  light,
@@ -38,7 +38,6 @@ export class FullVoxelTemplate {
38
38
  };
39
39
  }
40
40
  index = Flat3DIndex.GetXZYOrder();
41
- position = Vector3Like.Create();
42
41
  bounds;
43
42
  ids;
44
43
  level;
@@ -46,26 +45,20 @@ export class FullVoxelTemplate {
46
45
  secondary;
47
46
  mask;
48
47
  constructor(data) {
49
- this.position = { ...data.position };
50
- this.bounds = new BoundingBox();
51
- this.bounds.setMinPositionAndSize(data.position, data.bounds);
52
- this.index.setBounds(data.bounds.x, data.bounds.y, data.bounds.z);
53
- this.ids = data.ids;
54
- this.level = data.level;
55
- this.light = data.light;
56
- this.secondary = data.secondary;
57
- if (data.mask)
58
- this.mask = data.mask;
48
+ this.fromJSON(data);
59
49
  }
60
- setPosition(x, y, z) {
61
- this.position.x = x;
62
- this.position.y = y;
63
- this.position.z = z;
50
+ inBounds(x, y, z) {
51
+ point.x = x + 0.5;
52
+ point.y = y + 0.5;
53
+ point.z = z + 0.5;
54
+ return this.bounds.intersectsPoint(point);
64
55
  }
65
56
  isAir(index) {
66
57
  return this.ids[index] === 0;
67
58
  }
68
59
  isIncluded(index) {
60
+ if (index < 0 || index >= this.index.size)
61
+ return false;
69
62
  if (this.mask) {
70
63
  return getBitArrayIndex(this.mask, index) === 1;
71
64
  }
@@ -93,10 +86,21 @@ export class FullVoxelTemplate {
93
86
  rawRef[3] = this.getSecondary(index);
94
87
  return rawRef;
95
88
  }
89
+ clone() {
90
+ const newTemplate = new FullVoxelTemplate({
91
+ type: "full",
92
+ bounds: { ...this.bounds.size },
93
+ ids: this.ids.slice(),
94
+ light: this.light.slice(),
95
+ level: this.level.slice(),
96
+ secondary: this.secondary.slice(),
97
+ ...(this.mask ? { mask: this.mask.slice() } : {}),
98
+ });
99
+ return newTemplate;
100
+ }
96
101
  toJSON() {
97
102
  return {
98
103
  type: "full",
99
- position: this.position,
100
104
  bounds: this.bounds.size,
101
105
  ids: this.ids,
102
106
  light: this.light,
@@ -105,4 +109,15 @@ export class FullVoxelTemplate {
105
109
  ...(this.mask ? { mask: this.mask } : {}),
106
110
  };
107
111
  }
112
+ fromJSON(data) {
113
+ this.bounds = new BoundingBox();
114
+ this.bounds.setSize(data.bounds);
115
+ this.index.setBounds(data.bounds.x, data.bounds.y, data.bounds.z);
116
+ this.ids = data.ids;
117
+ this.level = data.level;
118
+ this.light = data.light;
119
+ this.secondary = data.secondary;
120
+ if (data.mask)
121
+ this.mask = data.mask;
122
+ }
108
123
  }
@@ -0,0 +1,5 @@
1
+ import { IVoxelSelection } from "../Selection/VoxelSelection";
2
+ import { DataCursorInterface } from "../../Voxels/Cursor/DataCursor.interface";
3
+ import { FullVoxelTemplate } from "../Full/FullVoxelTemplate";
4
+ import { Vector3Like } from "@amodx/math";
5
+ export declare function ExtrudeSelection(cursor: DataCursorInterface, selection: IVoxelSelection, normal: Vector3Like): FullVoxelTemplate;
@@ -0,0 +1,44 @@
1
+ import { FullVoxelTemplate } from "../Full/FullVoxelTemplate";
2
+ export function ExtrudeSelection(cursor, selection, normal) {
3
+ const size = selection.bounds.size;
4
+ const template = new FullVoxelTemplate(FullVoxelTemplate.CreateNew([size.x, size.y, size.z]));
5
+ for (let x = selection.origin.x; x < selection.origin.x + size.x; x++) {
6
+ for (let y = selection.origin.y; y < selection.origin.y + size.y; y++) {
7
+ for (let z = selection.origin.z; z < selection.origin.z + size.z; z++) {
8
+ if (selection.isSelected(x, y, z)) {
9
+ let nx = x;
10
+ let ny = y;
11
+ let nz = z;
12
+ const index = template.getIndex(x - selection.origin.x, y - selection.origin.y, z - selection.origin.z);
13
+ while (true) {
14
+ nx -= normal.x;
15
+ ny -= normal.y;
16
+ nz -= normal.z;
17
+ if (!selection.isSelected(nx, ny, nz)) {
18
+ const voxel = cursor.getVoxel(nx, ny, nz);
19
+ if (!voxel || voxel.isAir())
20
+ break;
21
+ template.ids[index] = voxel.ids[voxel._index];
22
+ template.level[index] = voxel.level[voxel._index];
23
+ template.secondary[index] = voxel.secondary[voxel._index];
24
+ break;
25
+ }
26
+ if (x < selection.origin.x || x >= selection.origin.x + size.x)
27
+ continue;
28
+ if (y < selection.origin.y || y >= selection.origin.y + size.y)
29
+ continue;
30
+ if (z < selection.origin.z || z >= selection.origin.z + size.z)
31
+ continue;
32
+ const nIndex = template.getIndex(nx - selection.origin.x, ny - selection.origin.y, nz - selection.origin.z);
33
+ if (!template.isAir(nIndex)) {
34
+ template.ids[index] = template.ids[nIndex];
35
+ template.level[index] = template.level[nIndex];
36
+ template.secondary[index] = template.secondary[nIndex];
37
+ }
38
+ }
39
+ }
40
+ }
41
+ }
42
+ }
43
+ return template;
44
+ }
@@ -0,0 +1,4 @@
1
+ import { IVoxelSelection } from "../Selection/VoxelSelection";
2
+ import { FullVoxelTemplate } from "../Full/FullVoxelTemplate";
3
+ import { PaintVoxelData } from "../../Voxels/Types/PaintVoxelData";
4
+ export declare function FillSelection(voxel: PaintVoxelData, selection: IVoxelSelection): FullVoxelTemplate;
@@ -0,0 +1,20 @@
1
+ import { FullVoxelTemplate } from "../Full/FullVoxelTemplate";
2
+ import { PaintVoxelData } from "../../Voxels/Types/PaintVoxelData";
3
+ export function FillSelection(voxel, selection) {
4
+ const size = selection.bounds.size;
5
+ const template = new FullVoxelTemplate(FullVoxelTemplate.CreateNew([size.x, size.y, size.z]));
6
+ const raw = PaintVoxelData.ToRaw(voxel);
7
+ for (let x = selection.origin.x; x < selection.origin.x + size.x; x++) {
8
+ for (let y = selection.origin.y; y < selection.origin.y + size.y; y++) {
9
+ for (let z = selection.origin.z; z < selection.origin.z + size.z; z++) {
10
+ if (selection.isSelected(x, y, z)) {
11
+ const index = template.getIndex(x - selection.origin.x, y - selection.origin.y, z - selection.origin.z);
12
+ template.ids[index] = raw[0];
13
+ template.level[index] = raw[2];
14
+ template.secondary[index] = raw[3];
15
+ }
16
+ }
17
+ }
18
+ }
19
+ return template;
20
+ }
@@ -1,3 +1,3 @@
1
+ import { Vector3Axes } from "@amodx/math";
1
2
  import { FullVoxelTemplate } from "../../Templates/Full/FullVoxelTemplate";
2
- export type TemplateFlipDirections = "x" | "z" | "y";
3
- export default function FlipTemplate(template: FullVoxelTemplate, direction: TemplateFlipDirections): void;
3
+ export default function FlipTemplate(template: FullVoxelTemplate, axes: Vector3Axes): void;
@@ -1,18 +1,18 @@
1
1
  import { Flat3DIndex } from "@amodx/math";
2
- const flipArray = ([sizeX, sizeY, sizeZ], array, direction, index) => {
2
+ const flipArray = ([sizeX, sizeY, sizeZ], array, axes, index) => {
3
3
  const newArray = new Array(array.length);
4
4
  for (let x = 0; x < sizeX; x++) {
5
5
  for (let y = 0; y < sizeY; y++) {
6
6
  for (let z = 0; z < sizeZ; z++) {
7
7
  const oldIndex = index.getIndexXYZ(x, y, z);
8
8
  let newCoords = [x, y, z];
9
- if (direction === "x") {
9
+ if (axes === "x") {
10
10
  newCoords[0] = sizeX - 1 - x;
11
11
  }
12
- else if (direction === "y") {
12
+ else if (axes === "y") {
13
13
  newCoords[1] = sizeY - 1 - y;
14
14
  }
15
- else if (direction === "z") {
15
+ else if (axes === "z") {
16
16
  newCoords[2] = sizeZ - 1 - z;
17
17
  }
18
18
  const newIndexFlat = index.getIndexXYZ(...newCoords);
@@ -24,20 +24,20 @@ const flipArray = ([sizeX, sizeY, sizeZ], array, direction, index) => {
24
24
  array[i] = newArray[i];
25
25
  }
26
26
  };
27
- export default function FlipTemplate(template, direction) {
27
+ export default function FlipTemplate(template, axes) {
28
28
  const { x: sizeX, y: sizeY, z: sizeZ } = template.bounds.size;
29
29
  const index = Flat3DIndex.GetXZYOrder();
30
30
  index.setBounds(sizeX, sizeY, sizeZ);
31
31
  if (typeof template.ids === "object") {
32
32
  const ids = template.ids;
33
- flipArray([sizeX, sizeY, sizeZ], ids, direction, index);
33
+ flipArray([sizeX, sizeY, sizeZ], ids, axes, index);
34
34
  }
35
35
  if (typeof template.level === "object") {
36
36
  const level = template.level;
37
- flipArray([sizeX, sizeY, sizeZ], level, direction, index);
37
+ flipArray([sizeX, sizeY, sizeZ], level, axes, index);
38
38
  }
39
39
  if (typeof template.secondary === "object") {
40
40
  const secondary = template.secondary;
41
- flipArray([sizeX, sizeY, sizeZ], secondary, direction, index);
41
+ flipArray([sizeX, sizeY, sizeZ], secondary, axes, index);
42
42
  }
43
43
  }
@@ -1,4 +1,4 @@
1
+ import { Vector3Axes } from "@amodx/math";
1
2
  import { FullVoxelTemplate } from "../Full/FullVoxelTemplate";
2
- export type TemplateRotationAxes = "x" | "y" | "z";
3
3
  export type TemplateRotationAngles = 90 | 180 | 270 | -90 | -180 | -270;
4
- export default function RotateTemplate(template: FullVoxelTemplate, angle: TemplateRotationAngles, axes?: TemplateRotationAxes): void;
4
+ export default function RotateTemplate(template: FullVoxelTemplate, angle: TemplateRotationAngles, axes?: Vector3Axes): void;
@@ -12,6 +12,7 @@ export declare class VoxelPathSegment extends TypedEventTarget<VoxelPathSegments
12
12
  start: Vec3Array;
13
13
  end: Vec3Array;
14
14
  voxel: PaintVoxelData;
15
+ transient: boolean;
15
16
  constructor(path: VoxelPath, index: number, data: VoxelPathSegmentData);
16
17
  setPoints([sx, sy, sz]: Vec3Array, [ex, ey, ez]: Vec3Array): void;
17
18
  getPoint(point: 0 | 1): Vec3Array;
@@ -27,6 +28,9 @@ export declare class VoxelPath extends TypedEventTarget<VoxelPathEvents> {
27
28
  static CreateNew(data: Partial<VoxelPathData>): VoxelPathData;
28
29
  segments: VoxelPathSegment[];
29
30
  constructor(data: VoxelPathData);
31
+ get totalSegments(): number;
32
+ lastSegment(): VoxelPathSegment | null;
33
+ firstSegment(): VoxelPathSegment | null;
30
34
  addSegment(data: VoxelPathSegmentData): boolean;
31
35
  removeSegment(segment: VoxelPathSegment): boolean;
32
36
  removePoint(segmentIndex: number, pointIndex: 0 | 1): false | undefined;
@@ -8,11 +8,13 @@ export class VoxelPathSegment extends TypedEventTarget {
8
8
  start: data.start ? data.start : [0, 0, 0],
9
9
  end: data.end ? data.end : [0, 0, 0],
10
10
  voxel: data.voxel ? data.voxel : PaintVoxelData.Create(),
11
+ transient: data.transient ? data.transient : undefined,
11
12
  };
12
13
  }
13
14
  start;
14
15
  end;
15
16
  voxel;
17
+ transient = false;
16
18
  constructor(path, index, data) {
17
19
  super();
18
20
  this.path = path;
@@ -20,6 +22,7 @@ export class VoxelPathSegment extends TypedEventTarget {
20
22
  this.start = data.start;
21
23
  this.end = data.end;
22
24
  this.voxel = data.voxel;
25
+ this.transient = data.transient || false;
23
26
  }
24
27
  setPoints([sx, sy, sz], [ex, ey, ez]) {
25
28
  let updated = false;
@@ -60,6 +63,7 @@ export class VoxelPathSegment extends TypedEventTarget {
60
63
  start: [...this.start],
61
64
  end: [...this.end],
62
65
  voxel: { ...this.voxel },
66
+ ...(this.transient ? { transient: true } : {}),
63
67
  };
64
68
  }
65
69
  }
@@ -78,6 +82,19 @@ export class VoxelPath extends TypedEventTarget {
78
82
  this.segments.push(new VoxelPathSegment(this, i, data.segments[i]));
79
83
  }
80
84
  }
85
+ get totalSegments() {
86
+ return this.segments.length;
87
+ }
88
+ lastSegment() {
89
+ if (!this.segments.length)
90
+ return null;
91
+ return this.segments[(this.totalSegments - 1) % this.totalSegments];
92
+ }
93
+ firstSegment() {
94
+ if (!this.segments.length)
95
+ return null;
96
+ return this.segments[0];
97
+ }
81
98
  addSegment(data) {
82
99
  const segment = new VoxelPathSegment(this, this.segments.length, data);
83
100
  this.segments.push(segment);
@@ -88,6 +105,7 @@ export class VoxelPath extends TypedEventTarget {
88
105
  for (let i = this.segments.length - 1; i > -1; i--) {
89
106
  this.segments[i].index--;
90
107
  if (this.segments[i] == segment) {
108
+ console.log("found segment to remove", i);
91
109
  this.segments.splice(i, 1);
92
110
  break;
93
111
  }
@@ -4,6 +4,7 @@ export type VoxelPathSegmentData = {
4
4
  start: Vec3Array;
5
5
  end: Vec3Array;
6
6
  voxel: PaintVoxelData;
7
+ transient?: boolean;
7
8
  };
8
9
  export type VoxelPathData = {
9
10
  segments: VoxelPathSegmentData[];
@@ -1,20 +1,20 @@
1
1
  import { Flat3DIndex, Vector3Like } from "@amodx/math";
2
- import { IVoxelSelection } from "./VoxelSelecton";
2
+ import { IVoxelSelection, IVoxelSelectionData } from "./VoxelSelection";
3
3
  import { DataCursorInterface } from "../../Voxels/Cursor/DataCursor.interface";
4
4
  import { FullVoxelTemplate } from "../Full/FullVoxelTemplate";
5
- export interface VoxelBFSSelectionData {
6
- origin: Vector3Like;
7
- size: Vector3Like;
5
+ import { BoundingBox } from "@amodx/math/Geomtry/Bounds/BoundingBox";
6
+ export interface VoxelBFSSelectionData extends IVoxelSelectionData<"bfs"> {
8
7
  bitIndex: Uint8Array;
9
8
  }
10
- export declare class VoxelBFSSelection implements IVoxelSelection, VoxelBFSSelectionData {
9
+ export declare class VoxelBFSSelection implements IVoxelSelection<"bfs", VoxelBFSSelectionData> {
11
10
  origin: Vector3Like;
12
- size: Vector3Like;
13
11
  bitIndex: Uint8Array;
14
12
  index: Flat3DIndex;
13
+ bounds: BoundingBox;
15
14
  isSelected(x: number, y: number, z: number): boolean;
16
15
  reConstruct(cursor: DataCursorInterface, position: Vector3Like, maxSize?: number): false | undefined;
17
16
  toTemplate(cursor: DataCursorInterface): FullVoxelTemplate;
17
+ clone(): VoxelBFSSelection;
18
18
  toJSON(): VoxelBFSSelectionData;
19
19
  fromJSON(data: VoxelBFSSelectionData): void;
20
20
  }
@@ -2,17 +2,14 @@ import { Flat3DIndex, Vector3Like } from "@amodx/math";
2
2
  import { CardinalNeighbors3D } from "../../Math/CardinalNeighbors";
3
3
  import { getBitArrayIndex, setBitArrayIndex, } from "../../Util/Binary/BinaryArrays";
4
4
  import { FullVoxelTemplate } from "../Full/FullVoxelTemplate";
5
+ import { BoundingBox } from "@amodx/math/Geomtry/Bounds/BoundingBox";
5
6
  export class VoxelBFSSelection {
6
7
  origin = Vector3Like.Create();
7
- size = Vector3Like.Create();
8
8
  bitIndex;
9
9
  index = Flat3DIndex.GetXZYOrder();
10
+ bounds = new BoundingBox();
10
11
  isSelected(x, y, z) {
11
- if (x < this.origin.x || x >= this.origin.x + this.size.x)
12
- return false;
13
- if (y < this.origin.y || y >= this.origin.y + this.size.y)
14
- return false;
15
- if (z < this.origin.z || z >= this.origin.z + this.size.z)
12
+ if (!this.bounds.intersectsXYZ(x + 0.5, y + 0.5, z + 0.5))
16
13
  return false;
17
14
  return (getBitArrayIndex(this.bitIndex, this.index.getIndexXYZ(x - this.origin.x, y - this.origin.y, z - this.origin.z)) === 1);
18
15
  }
@@ -78,24 +75,23 @@ export class VoxelBFSSelection {
78
75
  }
79
76
  }
80
77
  }
81
- this.size.x = sizeX;
82
- this.size.y = sizeY;
83
- this.size.z = sizeZ;
84
78
  this.origin.x = min.x;
85
79
  this.origin.y = min.y;
86
80
  this.origin.z = min.z;
81
+ this.bounds.setMinMax(this.origin, {
82
+ x: this.origin.x + sizeX,
83
+ y: this.origin.y + sizeY,
84
+ z: this.origin.z + sizeZ,
85
+ });
87
86
  }
88
87
  toTemplate(cursor) {
89
- const templateData = FullVoxelTemplate.CreateNew([
90
- this.size.x,
91
- this.size.y,
92
- this.size.z,
93
- ]);
88
+ const size = this.bounds.size;
89
+ const templateData = FullVoxelTemplate.CreateNew([size.x, size.y, size.z]);
94
90
  templateData.mask = this.bitIndex.slice();
95
91
  const template = new FullVoxelTemplate(templateData);
96
- for (let x = this.origin.x; x < this.origin.x + this.size.x; x++) {
97
- for (let y = this.origin.y; y < this.origin.y + this.size.y; y++) {
98
- for (let z = this.origin.z; z < this.origin.z + this.size.z; z++) {
92
+ for (let x = this.origin.x; x < this.origin.x + size.x; x++) {
93
+ for (let y = this.origin.y; y < this.origin.y + size.y; y++) {
94
+ for (let z = this.origin.z; z < this.origin.z + size.z; z++) {
99
95
  if (!this.isSelected(x, y, z))
100
96
  continue;
101
97
  const voxel = cursor.getVoxel(x, y, z);
@@ -110,10 +106,19 @@ export class VoxelBFSSelection {
110
106
  }
111
107
  return template;
112
108
  }
109
+ clone() {
110
+ const newSelection = new VoxelBFSSelection();
111
+ Vector3Like.Copy(newSelection.origin, this.origin);
112
+ newSelection.bounds.setMinMax(this.bounds.min, this.bounds.max);
113
+ newSelection.bitIndex = this.bitIndex.slice();
114
+ newSelection.index.setBounds(...this.index.getBounds());
115
+ return newSelection;
116
+ }
113
117
  toJSON() {
114
118
  return {
119
+ type: "bfs",
115
120
  origin: { ...this.origin },
116
- size: { ...this.size },
121
+ bounds: { ...this.bounds.size },
117
122
  bitIndex: this.bitIndex.slice(),
118
123
  };
119
124
  }
@@ -121,10 +126,12 @@ export class VoxelBFSSelection {
121
126
  this.origin.x = data.origin.x;
122
127
  this.origin.y = data.origin.y;
123
128
  this.origin.z = data.origin.z;
124
- this.size.x = data.size.x;
125
- this.size.y = data.size.y;
126
- this.size.z = data.size.z;
127
129
  this.bitIndex = data.bitIndex;
128
- this.index.setBounds(this.size.x, this.size.y, this.size.z);
130
+ this.bounds.setMinMax(this.origin, {
131
+ x: this.origin.x + data.bounds.x,
132
+ y: this.origin.y + data.bounds.y,
133
+ z: this.origin.z + data.bounds.z,
134
+ });
135
+ this.index.setBounds(data.bounds.x, data.bounds.y, data.bounds.z);
129
136
  }
130
137
  }
@@ -0,0 +1,20 @@
1
+ import { Vector3Like } from "@amodx/math";
2
+ import { IVoxelSelection, IVoxelSelectionData } from "./VoxelSelection";
3
+ import { VoxelShapeTemplate } from "../Shapes/VoxelShapeTemplate";
4
+ import { IVoxelshapeTemplateBaseData } from "../Shapes/VoxelShapeTemplate.types";
5
+ import { DataCursorInterface } from "../../Voxels/Cursor/DataCursor.interface";
6
+ import { BoundingBox } from "@amodx/math/Geomtry/Bounds/BoundingBox";
7
+ export interface VoxelBoundsSelectionData extends IVoxelSelectionData<"bounds"> {
8
+ }
9
+ export declare class VoxelBoundsSelection implements IVoxelSelection<"bounds", VoxelBoundsSelectionData> {
10
+ origin: Vector3Like;
11
+ end: Vector3Like;
12
+ bounds: BoundingBox;
13
+ isSelected(x: number, y: number, z: number): boolean;
14
+ reConstruct(startPosition: Vector3Like, startNormal: Vector3Like, endPosition: Vector3Like, endNormal: Vector3Like, offset?: number): void;
15
+ clone(): VoxelBoundsSelection;
16
+ toTemplate(data?: Partial<IVoxelshapeTemplateBaseData>): VoxelShapeTemplate;
17
+ toExtrudedTemplate(cursor: DataCursorInterface, normal: Vector3Like): void;
18
+ toJSON(): VoxelBoundsSelectionData;
19
+ fromJSON(data: VoxelBoundsSelectionData): void;
20
+ }
@@ -1,5 +1,7 @@
1
1
  import { Vec3ArrayLike, Vector3Like } from "@amodx/math";
2
- import { BoxVoxelTemplate } from "../Shapes/BoxVoxelTemplate";
2
+ import { VoxelShapeTemplate } from "../Shapes/VoxelShapeTemplate";
3
+ import { BoxVoxelShapeSelection } from "../Shapes/Selections/BoxVoxelShapeSelection";
4
+ import { BoundingBox } from "@amodx/math/Geomtry/Bounds/BoundingBox";
3
5
  const getMinMax = (...points) => {
4
6
  if (points.length === 0) {
5
7
  throw new Error("At least one point is required to calculate min/max.");
@@ -21,16 +23,12 @@ const getMinMax = (...points) => {
21
23
  const getSize = (start, end) => {
22
24
  return Vector3Like.Create(end.x - start.x, end.y - start.y, end.z - start.z);
23
25
  };
24
- export class VoxelBoxSelection {
26
+ export class VoxelBoundsSelection {
25
27
  origin = Vector3Like.Create();
26
28
  end = Vector3Like.Create();
27
- size = Vector3Like.Create();
29
+ bounds = new BoundingBox();
28
30
  isSelected(x, y, z) {
29
- if (x < this.origin.x || x >= this.end.x)
30
- return false;
31
- if (y < this.origin.y || y >= this.end.y)
32
- return false;
33
- if (z < this.origin.z || z >= this.end.z)
31
+ if (!this.bounds.intersectsXYZ(x + 0.5, y + 0.5, z + 0.5))
34
32
  return false;
35
33
  return true;
36
34
  }
@@ -76,9 +74,6 @@ export class VoxelBoxSelection {
76
74
  this.end.x = startPosition.x + startNormal.x;
77
75
  this.end.y = startPosition.y + startNormal.y;
78
76
  this.end.z = startPosition.z + startNormal.z;
79
- this.size.x = 1;
80
- this.size.y = 1;
81
- this.size.z = 1;
82
77
  }
83
78
  else {
84
79
  this.origin.x = finalMin[0];
@@ -87,19 +82,42 @@ export class VoxelBoxSelection {
87
82
  this.end.x = finalMax[0];
88
83
  this.end.y = finalMax[1];
89
84
  this.end.z = finalMax[2];
90
- this.size.x = finalSize[0];
91
- this.size.y = finalSize[1];
92
- this.size.z = finalSize[2];
93
85
  }
86
+ this.bounds.setMinMax(this.origin, this.end);
87
+ }
88
+ clone() {
89
+ const newSelection = new VoxelBoundsSelection();
90
+ Vector3Like.Copy(newSelection.origin, this.origin);
91
+ Vector3Like.Copy(newSelection.end, this.end);
92
+ newSelection.bounds.setMinMax(this.bounds.min, this.bounds.max);
93
+ return newSelection;
94
94
  }
95
95
  toTemplate(data) {
96
- const boxTemplate = BoxVoxelTemplate.CreateNew({
97
- width: this.size.x,
98
- height: this.size.y,
99
- depth: this.size.z,
96
+ return new VoxelShapeTemplate(VoxelShapeTemplate.CreateNew({
97
+ shapeSelection: BoxVoxelShapeSelection.CreateNew({
98
+ width: this.bounds.size.x,
99
+ height: this.bounds.size.y,
100
+ depth: this.bounds.size.z,
101
+ }),
100
102
  ...(data ? data : {}),
101
- });
102
- return new BoxVoxelTemplate(boxTemplate);
103
+ }));
103
104
  }
104
105
  toExtrudedTemplate(cursor, normal) { }
106
+ toJSON() {
107
+ return {
108
+ type: "bounds",
109
+ origin: { ...this.origin },
110
+ bounds: { ...this.bounds.size },
111
+ };
112
+ }
113
+ fromJSON(data) {
114
+ this.origin.x = data.origin.x;
115
+ this.origin.y = data.origin.y;
116
+ this.origin.z = data.origin.z;
117
+ this.bounds.setMinMax(this.origin, {
118
+ x: this.origin.x + data.bounds.x,
119
+ y: this.origin.y + data.bounds.y,
120
+ z: this.origin.z + data.bounds.z,
121
+ });
122
+ }
105
123
  }
@@ -0,0 +1,19 @@
1
+ import { Vector3Like } from "@amodx/math";
2
+ import { IVoxelSelection, IVoxelSelectionData } from "./VoxelSelection";
3
+ import { VoxelShapeTemplate } from "../Shapes/VoxelShapeTemplate";
4
+ import { IVoxelshapeTemplateBaseData } from "../Shapes/VoxelShapeTemplate.types";
5
+ import { DataCursorInterface } from "../../Voxels/Cursor/DataCursor.interface";
6
+ import { BoundingBox } from "@amodx/math/Geomtry/Bounds/BoundingBox";
7
+ export interface VoxelPointSelectionData extends IVoxelSelectionData<"point"> {
8
+ }
9
+ export declare class VoxelPointSelection implements IVoxelSelection<"point", VoxelPointSelectionData> {
10
+ origin: Vector3Like;
11
+ bounds: BoundingBox;
12
+ isSelected(x: number, y: number, z: number): boolean;
13
+ reConstruct(position: Vector3Like): void;
14
+ clone(): VoxelPointSelection;
15
+ toTemplate(data?: Partial<IVoxelshapeTemplateBaseData>): VoxelShapeTemplate;
16
+ toExtrudedTemplate(cursor: DataCursorInterface, normal: Vector3Like): void;
17
+ toJSON(): VoxelPointSelectionData;
18
+ fromJSON(data: any): void;
19
+ }
@@ -0,0 +1,49 @@
1
+ import { Vector3Like } from "@amodx/math";
2
+ import { VoxelShapeTemplate } from "../Shapes/VoxelShapeTemplate";
3
+ import { BoxVoxelShapeSelection } from "../Shapes/Selections/BoxVoxelShapeSelection";
4
+ import { BoundingBox } from "@amodx/math/Geomtry/Bounds/BoundingBox";
5
+ export class VoxelPointSelection {
6
+ origin = Vector3Like.Create();
7
+ bounds = new BoundingBox();
8
+ isSelected(x, y, z) {
9
+ if (!this.bounds.intersectsXYZ(x + 0.5, y + 0.5, z + 0.5))
10
+ return false;
11
+ return true;
12
+ }
13
+ reConstruct(position) {
14
+ this.origin.x = position.x;
15
+ this.origin.y = position.y;
16
+ this.origin.z = position.z;
17
+ this.bounds.setMinMax(this.origin, Vector3Like.AddScalar(this.origin, 1));
18
+ }
19
+ clone() {
20
+ const newSelection = new VoxelPointSelection();
21
+ Vector3Like.Copy(newSelection.origin, this.origin);
22
+ newSelection.bounds.setMinMax(this.bounds.min, this.bounds.max);
23
+ return newSelection;
24
+ }
25
+ toTemplate(data) {
26
+ return new VoxelShapeTemplate(VoxelShapeTemplate.CreateNew({
27
+ shapeSelection: BoxVoxelShapeSelection.CreateNew({}),
28
+ ...data,
29
+ }));
30
+ }
31
+ toExtrudedTemplate(cursor, normal) { }
32
+ toJSON() {
33
+ return {
34
+ type: "point",
35
+ origin: { ...this.origin },
36
+ bounds: { ...this.bounds.size },
37
+ };
38
+ }
39
+ fromJSON(data) {
40
+ this.origin.x = data.origin.x;
41
+ this.origin.y = data.origin.y;
42
+ this.origin.z = data.origin.z;
43
+ this.bounds.setMinMax(this.origin, {
44
+ x: this.origin.x + data.bounds.x,
45
+ y: this.origin.y + data.bounds.y,
46
+ z: this.origin.z + data.bounds.z,
47
+ });
48
+ }
49
+ }
@@ -0,0 +1,18 @@
1
+ import { Vector3Like } from "@amodx/math";
2
+ import { BoundingBox } from "@amodx/math/Geomtry/Bounds/BoundingBox";
3
+ export interface IVoxelSelection<Type extends string = "", Data extends IVoxelSelectionData<Type> = any> {
4
+ origin: Vector3Like;
5
+ bounds: BoundingBox;
6
+ isSelected(x: number, y: number, z: number): boolean;
7
+ clone(): IVoxelSelection;
8
+ toJSON(): Data;
9
+ fromJSON(data: Data): void;
10
+ }
11
+ export interface IVoxelSelectionData<Type extends string> {
12
+ type: Type;
13
+ origin: Vector3Like;
14
+ bounds: Vector3Like;
15
+ }
16
+ export interface IVoxelSelectionConstructor<Type extends string, Data extends IVoxelSelectionData<Type> = any> {
17
+ new (): IVoxelSelection<Type, Data>;
18
+ }
@@ -0,0 +1 @@
1
+ export {};