@divinevoxel/vlox 0.0.73 → 0.0.74

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 (217) hide show
  1. package/Contexts/Base/Remote/InitDataSync.js +4 -0
  2. package/Contexts/Base/Remote/InitWorldDataSync.js +1 -1
  3. package/Contexts/Render/DivineVoxelEngineRender.d.ts +1 -0
  4. package/Contexts/World/DivineVoxelEngineWorld.d.ts +1 -0
  5. package/Init/StartConstructor.js +2 -0
  6. package/Math/index.d.ts +5 -1
  7. package/Mesher/Functions/CompactVoxelSectionMesh.d.ts +4 -0
  8. package/Mesher/Functions/CompactVoxelSectionMesh.js +112 -0
  9. package/Mesher/Functions/MeshSection.d.ts +1 -1
  10. package/Mesher/Functions/MeshSection.js +15 -22
  11. package/Mesher/Geomtry/CompactedSectionVoxelMesh.d.ts +23 -0
  12. package/Mesher/Geomtry/CompactedSectionVoxelMesh.js +144 -0
  13. package/Mesher/Geomtry/VoxelGeometryBuilder.d.ts +1 -1
  14. package/Mesher/Geomtry/VoxelGeometryBuilder.js +118 -197
  15. package/Mesher/Geomtry/VoxelMesh.js +2 -2
  16. package/Mesher/Geomtry/VoxelMeshBVHBuilder.d.ts +8 -70
  17. package/Mesher/Geomtry/VoxelMeshBVHBuilder.js +18 -183
  18. package/Mesher/Geomtry/VoxelMeshBVHStructCursor.d.ts +22 -0
  19. package/Mesher/Geomtry/VoxelMeshBVHStructCursor.js +78 -0
  20. package/Mesher/Geomtry/VoxelMeshBuffers.js +2 -2
  21. package/Mesher/InitTask.js +5 -1
  22. package/Mesher/Models/Common/BoxGeometryNode.js +7 -7
  23. package/Mesher/Models/Common/Calc/CalcConstants.d.ts +1 -1
  24. package/Mesher/Models/Common/Calc/CalcConstants.js +1 -1
  25. package/Mesher/Models/Common/QuadGeometryNode.js +2 -2
  26. package/Mesher/Models/Nodes/Custom/Liquid/LiquidGeomtryNode.js +7 -7
  27. package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.js +22 -25
  28. package/Mesher/Models/Nodes/Ruled/QuadVoxelGeometryNode.js +2 -2
  29. package/Mesher/Models/Nodes/Ruleless/RulelessBoxVoxelGeometryNode.js +2 -2
  30. package/Mesher/Models/Nodes/Ruleless/RulelessQuadVoxelGeometryNode.js +2 -2
  31. package/Mesher/Models/VoxelConstructor.d.ts +3 -3
  32. package/Mesher/Models/VoxelConstructor.js +8 -8
  33. package/Mesher/Models/VoxelGeometryBuilderCacheSpace.d.ts +2 -2
  34. package/Mesher/Models/VoxelGeometryBuilderCacheSpace.js +8 -9
  35. package/Mesher/Models/VoxelModelBuilder.js +1 -8
  36. package/Mesher/Types/Mesher.types.d.ts +1 -0
  37. package/Models/Defaults/CubeVoxelModels.js +16 -39
  38. package/Models/Defaults/LiquidVoxelModel.js +3 -3
  39. package/Models/Defaults/PanelVoxelModels.js +10 -36
  40. package/Models/Defaults/StairVoxelModel.js +6 -21
  41. package/Models/Examples.js +23 -44
  42. package/Models/Rules/Classes/VoxelRulesModel.d.ts +1 -1
  43. package/Models/Rules/Classes/VoxelRulesModel.js +3 -3
  44. package/Models/Rules/Functions/BuildFinalInputs.d.ts +1 -1
  45. package/Models/Rules/Functions/BuildFinalInputs.js +13 -13
  46. package/Models/Rules/VoxelModelRuleBuilderRegister.js +8 -8
  47. package/Models/VoxelModel.types.d.ts +3 -3
  48. package/Renderer/Classes/DVESectionMeshes.d.ts +2 -3
  49. package/Renderer/InitTasks.js +1 -9
  50. package/Renderer/MeshManager.d.ts +1 -1
  51. package/Renderer/MeshManager.js +24 -23
  52. package/Renderer/MeshRegister.d.ts +5 -5
  53. package/Renderer/MeshRegister.js +2 -2
  54. package/Settings/EngineSettings.d.ts +1 -0
  55. package/Settings/EngineSettings.js +6 -3
  56. package/Settings/EngineSettings.types.d.ts +7 -21
  57. package/Settings/EngineSettings.types.js +6 -14
  58. package/Tasks/Logic/InitTasks.d.ts +1 -0
  59. package/Tasks/Logic/InitTasks.js +10 -0
  60. package/Tasks/Logic/VoxelLogicUpdate.d.ts +3 -0
  61. package/Tasks/Logic/VoxelLogicUpdate.js +71 -0
  62. package/Tasks/Propagation/Explosion/ExplosionManager.d.ts +2 -2
  63. package/Tasks/Propagation/Explosion/ExplosionManager.js +1 -2
  64. package/Tasks/Propagation/Flow/FlowManager.d.ts +4 -4
  65. package/Tasks/Propagation/Flow/FlowRemove.d.ts +2 -2
  66. package/Tasks/Propagation/Flow/FlowUpdate.d.ts +2 -2
  67. package/Tasks/Propagation/Flow/WorldFlow.d.ts +2 -2
  68. package/Tasks/Propagation/Illumanation/RGBUpdate.d.ts +3 -3
  69. package/Tasks/Propagation/Illumanation/SunUpdate.d.ts +3 -3
  70. package/Tasks/Propagation/Illumanation/WorldRGB.d.ts +2 -2
  71. package/Tasks/Propagation/Illumanation/WorldSun.d.ts +2 -2
  72. package/Tasks/Propagation/Illumanation/WorldSun.js +8 -15
  73. package/Tasks/Propagation/InitTasks.js +4 -4
  74. package/Tasks/Propagation/Power/PowerUpdate.d.ts +3 -0
  75. package/Tasks/Propagation/Power/PowerUpdate.js +80 -0
  76. package/Tasks/Tasks.types.d.ts +2 -2
  77. package/Tasks/TasksIds.d.ts +2 -1
  78. package/Tasks/TasksIds.js +1 -0
  79. package/Tasks/Update/Common.d.ts +3 -0
  80. package/Tasks/Update/Common.js +41 -0
  81. package/Tasks/Update/EreaseUpdate.d.ts +3 -0
  82. package/Tasks/Update/EreaseUpdate.js +66 -0
  83. package/Tasks/Update/InitTasks.d.ts +2 -2
  84. package/Tasks/Update/InitTasks.js +3 -1
  85. package/Tasks/Update/PaintUpdate.d.ts +3 -0
  86. package/Tasks/Update/PaintUpdate.js +89 -0
  87. package/Tasks/Update/VoxelUpdate.d.ts +2 -5
  88. package/Tasks/Update/VoxelUpdate.js +5 -147
  89. package/Tasks/{Update/UpdateTask.d.ts → VoxelUpdateTask.d.ts} +15 -7
  90. package/Tasks/{Update/UpdateTask.js → VoxelUpdateTask.js} +20 -7
  91. package/Tasks/WorldGeneration/WorldGenBrush.d.ts +3 -3
  92. package/Tasks/WorldGeneration/WorldGenBrush.js +2 -2
  93. package/Tasks/WorldGeneration/WorldGenRegister.d.ts +1 -1
  94. package/Templates/Functions/CreateTemplate.d.ts +1 -1
  95. package/Tools/Brush/AdvancedBrushTool.js +1 -1
  96. package/Tools/Brush/Brush.d.ts +2 -2
  97. package/Tools/Brush/Brush.js +1 -1
  98. package/Tools/Tasks/TasksTool.d.ts +1 -0
  99. package/Tools/Tasks/TasksTool.js +2 -0
  100. package/Util/Binary/BinaryBuffer.d.ts +17 -11
  101. package/Util/Binary/BinaryBuffer.js +65 -59
  102. package/Util/Binary/BinaryTree.d.ts +46 -0
  103. package/Util/Binary/BinaryTree.js +104 -0
  104. package/Voxels/Cursor/VoxelCursor.interface.d.ts +7 -2
  105. package/Voxels/Cursor/VoxelCursor.interface.js +46 -2
  106. package/Voxels/Cursor/VoxelLightData.js +1 -1
  107. package/Voxels/Data/VoxelTag.types.d.ts +17 -2
  108. package/Voxels/Data/VoxelTag.types.js +6 -1
  109. package/Voxels/Data/VoxelTagsRegister.js +5 -0
  110. package/Voxels/Functions/BuildStateData.d.ts +6 -6
  111. package/Voxels/Functions/BuildStateData.js +31 -31
  112. package/Voxels/Functions/BuildTagAndPaletteData.js +5 -0
  113. package/Voxels/Indexes/VoxelIndex.d.ts +2 -2
  114. package/Voxels/Indexes/VoxelIndex.js +16 -18
  115. package/Voxels/InitVoxelData.js +12 -8
  116. package/Voxels/Logic/Classes/Default/Types/VoxelPoweredLogicType.d.ts +5 -0
  117. package/Voxels/Logic/Classes/Default/Types/VoxelPoweredLogicType.js +6 -0
  118. package/Voxels/Logic/Classes/VoxelLogic.d.ts +11 -0
  119. package/Voxels/Logic/Classes/VoxelLogic.js +49 -0
  120. package/Voxels/Logic/Classes/VoxelLogicType.d.ts +4 -0
  121. package/Voxels/Logic/Classes/VoxelLogicType.js +2 -0
  122. package/Voxels/Logic/VoxelLogic.types.d.ts +23 -0
  123. package/Voxels/Logic/VoxelLogic.types.js +1 -0
  124. package/Voxels/Logic/VoxelLogicRegister.d.ts +9 -0
  125. package/Voxels/Logic/VoxelLogicRegister.js +15 -0
  126. package/Voxels/State/SchemaRegister.js +10 -5
  127. package/Voxels/State/State.types.d.ts +1 -1
  128. package/Voxels/State/StateTreeReader.d.ts +1 -1
  129. package/Voxels/State/StateTreeReader.js +2 -3
  130. package/Voxels/Types/Voxel.types.d.ts +3 -0
  131. package/Voxels/Types/VoxelModelCompiledData.types.d.ts +6 -4
  132. package/World/Archive/Archive.types.d.ts +31 -12
  133. package/World/Archive/Classes/ArchiveClasses.d.ts +66 -0
  134. package/World/Archive/Classes/ArchiveClasses.js +78 -0
  135. package/World/Archive/Classes/ImportedSection.d.ts +40 -0
  136. package/World/Archive/Classes/ImportedSection.js +307 -0
  137. package/World/Archive/Classes/ImportedSector.d.ts +23 -0
  138. package/World/Archive/Classes/ImportedSector.js +97 -0
  139. package/World/Archive/Functions/ArchiveArea.d.ts +1 -1
  140. package/World/Archive/Functions/ArchiveArea.js +39 -36
  141. package/World/Archive/Functions/ArchiveSector.js +210 -404
  142. package/World/Archive/Functions/CreateArchivedSection.d.ts +3 -0
  143. package/World/Archive/Functions/CreateArchivedSection.js +207 -0
  144. package/World/Archive/Functions/ImportSector.d.ts +1 -3
  145. package/World/Archive/Functions/ImportSector.js +13 -244
  146. package/World/Archive/Functions/RemoveDuplicates.d.ts +3 -0
  147. package/World/Archive/Functions/RemoveDuplicates.js +92 -0
  148. package/World/Archive/Functions/Shared.d.ts +2 -2
  149. package/World/Archive/Functions/Shared.js +15 -40
  150. package/World/Archive/InitTasks.js +7 -10
  151. package/World/Cursor/SectionCursor.d.ts +1 -1
  152. package/World/Cursor/SectorCursor.d.ts +1 -1
  153. package/World/Cursor/WorldCursor.d.ts +4 -3
  154. package/World/Cursor/WorldCursor.js +16 -13
  155. package/World/Cursor/WorldVoxelCursor.d.ts +0 -4
  156. package/World/Cursor/WorldVoxelCursor.js +23 -14
  157. package/World/Dimension/Dimension.d.ts +4 -1
  158. package/World/Dimension/Dimension.js +8 -1
  159. package/World/Section/Section.d.ts +17 -4
  160. package/World/Section/Section.js +68 -6
  161. package/World/Section/SectionState.d.ts +4 -2
  162. package/World/Section/SectionState.js +4 -2
  163. package/World/Sector/Sector.d.ts +7 -1
  164. package/World/Sector/Sector.js +37 -4
  165. package/World/Sector/SectorState.d.ts +3 -2
  166. package/World/Sector/SectorState.js +3 -2
  167. package/World/Types/WorldData.types.d.ts +2 -7
  168. package/World/WorldRegister.d.ts +9 -9
  169. package/World/WorldRegister.js +9 -6
  170. package/World/WorldSpaces.js +6 -6
  171. package/{Tasks/IWG → WorldSimulation}/Internal/Classes/DimensionSegment.d.ts +2 -2
  172. package/{Tasks/IWG → WorldSimulation}/Internal/Classes/Generator.d.ts +6 -4
  173. package/{Tasks/IWG → WorldSimulation}/Internal/Classes/Generator.js +9 -5
  174. package/WorldSimulation/Internal/Classes/Queues/BuildQueue.d.ts +5 -0
  175. package/WorldSimulation/Internal/Classes/Queues/BuildQueue.js +6 -0
  176. package/WorldSimulation/Internal/Classes/Queues/LogiccQueue.d.ts +5 -0
  177. package/WorldSimulation/Internal/Classes/Queues/LogiccQueue.js +6 -0
  178. package/{Tasks/IWG → WorldSimulation}/Internal/Classes/SectorVisistedMap.js +1 -1
  179. package/WorldSimulation/Internal/Classes/TickQueue.d.ts +12 -0
  180. package/{Tasks/IWG/Internal/Classes/BuildQueue.js → WorldSimulation/Internal/Classes/TickQueue.js} +16 -7
  181. package/WorldSimulation/Internal/Classes/WorldSimulationTaskBase.d.ts +15 -0
  182. package/{Tasks/IWG/Internal/Classes/IWGTaskBase.js → WorldSimulation/Internal/Classes/WorldSimulationTaskBase.js} +6 -6
  183. package/{Tasks/IWG → WorldSimulation}/Internal/Functions/cullSectors.js +9 -9
  184. package/{Tasks/IWG → WorldSimulation}/Internal/Functions/getSectorState.d.ts +1 -1
  185. package/{Tasks/IWG → WorldSimulation}/Internal/Functions/getSectorState.js +4 -4
  186. package/WorldSimulation/Internal/Functions/runTickUpdate.d.ts +2 -0
  187. package/{Tasks/IWG/Internal/Functions/runBuildUpdate.js → WorldSimulation/Internal/Functions/runTickUpdate.js} +29 -19
  188. package/{Tasks/IWG → WorldSimulation}/Internal/Functions/runWorldUpdate.js +13 -13
  189. package/{Tasks/IWG → WorldSimulation}/Internal/TaskRegister.d.ts +2 -2
  190. package/{Tasks/IWG → WorldSimulation}/Internal/TaskRegister.js +1 -1
  191. package/WorldSimulation/Internal/WorldSimulationDimensions.d.ts +6 -0
  192. package/{Tasks/IWG/Internal/IWGDimensions.js → WorldSimulation/Internal/WorldSimulationDimensions.js} +1 -1
  193. package/WorldSimulation/Internal/WorldSimulationTasks.d.ts +30 -0
  194. package/{Tasks/IWG/Internal/IWGTasks.js → WorldSimulation/Internal/WorldSimulationTasks.js} +14 -14
  195. package/WorldSimulation/Internal/WorldSimulationTools.d.ts +8 -0
  196. package/{Tasks/IWG/Internal/IWGTools.js → WorldSimulation/Internal/WorldSimulationTools.js} +1 -1
  197. package/{Tasks/IWG → WorldSimulation}/Procedures/InitalLoad.d.ts +1 -1
  198. package/{Tasks/IWG → WorldSimulation}/Procedures/InitalLoad.js +11 -11
  199. package/{Tasks/IWG → WorldSimulation}/Procedures/SaveAllSectors.js +5 -5
  200. package/{Tasks/IWG/IWG.d.ts → WorldSimulation/WorldSimulation.d.ts} +5 -5
  201. package/{Tasks/IWG/IWG.js → WorldSimulation/WorldSimulation.js} +21 -21
  202. package/{Tasks/IWG → WorldSimulation}/index.d.ts +1 -1
  203. package/{Tasks/IWG → WorldSimulation}/index.js +1 -1
  204. package/package.json +1 -1
  205. package/Tasks/IWG/Internal/Classes/BuildQueue.d.ts +0 -11
  206. package/Tasks/IWG/Internal/Classes/IWGTaskBase.d.ts +0 -15
  207. package/Tasks/IWG/Internal/Functions/runBuildUpdate.d.ts +0 -2
  208. package/Tasks/IWG/Internal/IWGDimensions.d.ts +0 -6
  209. package/Tasks/IWG/Internal/IWGTasks.d.ts +0 -30
  210. package/Tasks/IWG/Internal/IWGTools.d.ts +0 -8
  211. /package/{Tasks/IWG → WorldSimulation}/Internal/Classes/DimensionSegment.js +0 -0
  212. /package/{Tasks/IWG → WorldSimulation}/Internal/Classes/SectorState.d.ts +0 -0
  213. /package/{Tasks/IWG → WorldSimulation}/Internal/Classes/SectorState.js +0 -0
  214. /package/{Tasks/IWG → WorldSimulation}/Internal/Classes/SectorVisistedMap.d.ts +0 -0
  215. /package/{Tasks/IWG → WorldSimulation}/Internal/Functions/cullSectors.d.ts +0 -0
  216. /package/{Tasks/IWG → WorldSimulation}/Internal/Functions/runWorldUpdate.d.ts +0 -0
  217. /package/{Tasks/IWG → WorldSimulation}/Procedures/SaveAllSectors.d.ts +0 -0
@@ -0,0 +1,41 @@
1
+ import { EngineSettings as ES } from "../../Settings/EngineSettings.js";
2
+ import { $3dCardinalNeighbors } from "../../Math/CardinalNeighbors.js";
3
+ export const updateLightTask = (tasks) => {
4
+ let doRGB = ES.doRGBPropagation;
5
+ let doSun = ES.doSunPropagation;
6
+ const [dimension, x, y, z] = tasks.origin;
7
+ tasks.nDataCursor.setFocalPoint(dimension, x, y, z);
8
+ for (const n of $3dCardinalNeighbors) {
9
+ const nx = n[0] + x;
10
+ const ny = n[1] + y;
11
+ const nz = n[2] + z;
12
+ const nVoxel = tasks.nDataCursor.getVoxel(nx, ny, nz);
13
+ if (!nVoxel)
14
+ continue;
15
+ if (doRGB) {
16
+ if (nVoxel.hasRGBLight()) {
17
+ tasks.rgb.update.push(nx, ny, nz);
18
+ }
19
+ }
20
+ if (doSun) {
21
+ if (nVoxel.hasSunLight()) {
22
+ tasks.sun.update.push(nx, ny, nz);
23
+ }
24
+ }
25
+ }
26
+ };
27
+ export const updatePowerTask = (tasks) => {
28
+ const [dimension, x, y, z] = tasks.origin;
29
+ tasks.nDataCursor.setFocalPoint(dimension, x, y, z);
30
+ for (const n of $3dCardinalNeighbors) {
31
+ const nx = n[0] + x;
32
+ const ny = n[1] + y;
33
+ const nz = n[2] + z;
34
+ const nVoxel = tasks.nDataCursor.getVoxel(nx, ny, nz);
35
+ if (!nVoxel)
36
+ continue;
37
+ if (nVoxel.getPower() > 0) {
38
+ tasks.power.update.push(nx, ny, nz);
39
+ }
40
+ }
41
+ };
@@ -0,0 +1,3 @@
1
+ import { VoxelUpdateTask } from "../VoxelUpdateTask.js";
2
+ import { LocationData } from "../../Math/index.js";
3
+ export declare function EreaseAndUpdate(location: LocationData): Promise<false | VoxelUpdateTask>;
@@ -0,0 +1,66 @@
1
+ import { EngineSettings as ES } from "../../Settings/EngineSettings.js";
2
+ import { $3dCardinalNeighbors } from "../../Math/CardinalNeighbors.js";
3
+ import { VoxelUpdateTask } from "../VoxelUpdateTask.js";
4
+ import { RGBRemove, RGBUpdate } from "../Propagation/Illumanation/RGBUpdate.js";
5
+ import { SunUpdate } from "../Propagation/Illumanation/SunUpdate.js";
6
+ import { FlowRemove } from "../Propagation/Flow/FlowRemove.js";
7
+ import { updateLightTask } from "./Common.js";
8
+ import { PowerRemove, PowerUpdate } from "../Propagation/Power/PowerUpdate.js";
9
+ const tasks = new VoxelUpdateTask();
10
+ export async function EreaseAndUpdate(location) {
11
+ const [dimension, x, y, z] = location;
12
+ tasks.setOrigin(location);
13
+ let voxel = tasks.sDataCursor.getVoxel(x, y, z);
14
+ if (!voxel)
15
+ return false;
16
+ const substanceData = voxel.getSubstanceData();
17
+ const foundPower = voxel.getPower();
18
+ if (!voxel.isAir() && ES.doFlow && voxel.isRenderable()) {
19
+ if (substanceData["dve_is_liquid"]) {
20
+ FlowRemove(tasks);
21
+ return tasks;
22
+ }
23
+ }
24
+ voxel = tasks.sDataCursor.getVoxel(x, y, z);
25
+ const light = voxel.getLight();
26
+ const isLightSource = voxel.isLightSource();
27
+ voxel.setSecondary(true).setId(0).setSecondary(false);
28
+ voxel
29
+ .setLight(light > 0 ? light : 0)
30
+ .setId(0)
31
+ .setLevel(0)
32
+ .setLevelState(0)
33
+ .setState(0)
34
+ .setMod(0)
35
+ .updateVoxel(1);
36
+ if (ES.doLight) {
37
+ if (ES.doRGBPropagation && isLightSource) {
38
+ tasks.rgb.remove.push(x, y, z);
39
+ RGBRemove(tasks);
40
+ }
41
+ updateLightTask(tasks);
42
+ if (ES.doRGBPropagation) {
43
+ RGBUpdate(tasks);
44
+ }
45
+ if (ES.doSunPropagation) {
46
+ SunUpdate(tasks);
47
+ }
48
+ }
49
+ voxel = tasks.sDataCursor.getVoxel(x, y, z);
50
+ if (ES.doPower) {
51
+ if (foundPower > -1) {
52
+ voxel.setLevel(foundPower);
53
+ tasks.power.remove.push(x, y, z);
54
+ PowerRemove(tasks);
55
+ PowerUpdate(tasks);
56
+ }
57
+ }
58
+ tasks.bounds.update(x, y, z);
59
+ tasks.bounds.update(x + 1, y + 1, z + 1);
60
+ for (let i = 0; i < $3dCardinalNeighbors.length; i++) {
61
+ tasks.sDataCursor
62
+ .getVoxel($3dCardinalNeighbors[i][0] + x, $3dCardinalNeighbors[i][1] + y, $3dCardinalNeighbors[i][2] + z)
63
+ ?.updateVoxel(2);
64
+ }
65
+ return tasks;
66
+ }
@@ -1,5 +1,5 @@
1
1
  import { Thread } from "@amodx/threads";
2
- import { UpdateTask } from "./UpdateTask";
2
+ import { VoxelUpdateTask } from "../VoxelUpdateTask";
3
3
  export default function (props: {
4
- onDone(taks: UpdateTask, origin: Thread): void;
4
+ onDone(taks: VoxelUpdateTask, origin: Thread): void;
5
5
  }): void;
@@ -1,6 +1,8 @@
1
1
  import { Threads } from "@amodx/threads";
2
2
  import { TasksIds } from "../TasksIds";
3
- import { VoxelUpdate, EreaseAndUpdate, PaintAndUpdate } from "./VoxelUpdate";
3
+ import { VoxelUpdate } from "./VoxelUpdate";
4
+ import { EreaseAndUpdate } from "./EreaseUpdate";
5
+ import { PaintAndUpdate } from "./PaintUpdate";
4
6
  export default function (props) {
5
7
  Threads.registerTask(TasksIds.VoxelUpdate, async (data, origin) => {
6
8
  const tasks = await VoxelUpdate(data);
@@ -0,0 +1,3 @@
1
+ import { VoxelUpdateTasks } from "../Tasks.types.js";
2
+ import { VoxelUpdateTask } from "../VoxelUpdateTask.js";
3
+ export declare function PaintAndUpdate(data: VoxelUpdateTasks): Promise<false | VoxelUpdateTask>;
@@ -0,0 +1,89 @@
1
+ import { EngineSettings as ES } from "../../Settings/EngineSettings.js";
2
+ import { $3dCardinalNeighbors } from "../../Math/CardinalNeighbors.js";
3
+ import { VoxelUpdateTask } from "../VoxelUpdateTask.js";
4
+ import { RGBRemove, RGBUpdate } from "../Propagation/Illumanation/RGBUpdate.js";
5
+ import { SunRemove, SunUpdate } from "../Propagation/Illumanation/SunUpdate.js";
6
+ import { FlowUpdate } from "../Propagation/Flow/FlowUpdate.js";
7
+ import { updateLightTask, updatePowerTask } from "./Common.js";
8
+ import { PowerUpdate } from "../../Tasks/Propagation/Power/PowerUpdate.js";
9
+ const tasks = new VoxelUpdateTask();
10
+ export async function PaintAndUpdate(data) {
11
+ const [dimension, x, y, z] = data[0];
12
+ tasks.setOrigin(data[0]);
13
+ let voxel = tasks.sDataCursor.getVoxel(x, y, z);
14
+ if (!voxel)
15
+ return false;
16
+ const raw = data[1];
17
+ const isOpaque = voxel.isOpaque();
18
+ let doRGB = ES.doRGBPropagation;
19
+ let doSun = ES.doSunPropagation;
20
+ lighttest: if (ES.doLight) {
21
+ const light = voxel.getLight();
22
+ if (light <= 0)
23
+ break lighttest;
24
+ if (doSun) {
25
+ if (voxel.hasSunLight()) {
26
+ tasks.sun.remove.push(x, y, z);
27
+ SunRemove(tasks);
28
+ }
29
+ }
30
+ if (doRGB) {
31
+ if (voxel.hasRGBLight() && isOpaque) {
32
+ tasks.rgb.remove.push(x, y, z);
33
+ RGBRemove(tasks);
34
+ }
35
+ }
36
+ }
37
+ voxel = tasks.sDataCursor.getVoxel(x, y, z);
38
+ const id = raw[0];
39
+ if (id < 0)
40
+ return false;
41
+ voxel.setId(id);
42
+ voxel.setLevel(raw[2]);
43
+ voxel.setState(raw[3]);
44
+ voxel.setMod(raw[4]);
45
+ voxel.process();
46
+ if (raw[3] > 0 && voxel.canHaveSecondaryVoxel()) {
47
+ voxel.setSecondary(true);
48
+ voxel.setId(raw[5]);
49
+ voxel.setSecondary(false);
50
+ }
51
+ if (voxel.isLightSource() && voxel.getLightSourceValue()) {
52
+ voxel.setLight(voxel.getLightSourceValue());
53
+ }
54
+ voxel.updateVoxel(0);
55
+ if (ES.doLight) {
56
+ updateLightTask(tasks);
57
+ if (doRGB) {
58
+ tasks.rgb.update.push(x, y, z);
59
+ RGBUpdate(tasks);
60
+ }
61
+ if (doSun) {
62
+ SunUpdate(tasks);
63
+ }
64
+ }
65
+ voxel = tasks.sDataCursor.getVoxel(x, y, z);
66
+ if (ES.doFlow) {
67
+ if (!voxel.isAir() && voxel.getSubstanceData()["dve_is_liquid"]) {
68
+ FlowUpdate(tasks);
69
+ }
70
+ }
71
+ if (ES.doPower) {
72
+ if (voxel._tags["dve_can_be_powered"] ||
73
+ voxel._tags["dve_is_power_source"] ||
74
+ voxel._tags["dve_can_carry_power"] ||
75
+ voxel._tags["dve_can_hold_power"]) {
76
+ updatePowerTask(tasks);
77
+ tasks.power.update.push(x, y, z);
78
+ PowerUpdate(tasks);
79
+ }
80
+ }
81
+ tasks.bounds.update(x, y, z);
82
+ tasks.bounds.update(x + 1, y + 1, z + 1);
83
+ for (let i = 0; i < $3dCardinalNeighbors.length; i++) {
84
+ tasks.sDataCursor
85
+ .getVoxel($3dCardinalNeighbors[i][0] + x, $3dCardinalNeighbors[i][1] + y, $3dCardinalNeighbors[i][2] + z)
86
+ ?.updateVoxel(2);
87
+ }
88
+ return tasks;
89
+ }
@@ -1,6 +1,3 @@
1
1
  import { VoxelUpdateTasks } from "../Tasks.types.js";
2
- import { UpdateTask } from "./UpdateTask.js";
3
- import { LocationData } from "../../Math/index.js";
4
- export declare function EreaseAndUpdate(location: LocationData): Promise<false | UpdateTask>;
5
- export declare function PaintAndUpdate(data: VoxelUpdateTasks): Promise<false | UpdateTask>;
6
- export declare function VoxelUpdate(data: VoxelUpdateTasks): Promise<false | UpdateTask>;
2
+ import { VoxelUpdateTask } from "../VoxelUpdateTask.js";
3
+ export declare function VoxelUpdate(data: VoxelUpdateTasks): Promise<false | VoxelUpdateTask>;
@@ -1,152 +1,10 @@
1
1
  import { EngineSettings as ES } from "../../Settings/EngineSettings.js";
2
- import { $3dCardinalNeighbors } from "../../Math/CardinalNeighbors.js";
3
- import { UpdateTask } from "./UpdateTask.js";
4
- import { RGBRemove, RGBUpdate } from "../Propagation/Illumanation/RGBUpdate.js";
5
- import { SunRemove, SunUpdate } from "../Propagation/Illumanation/SunUpdate.js";
2
+ import { VoxelUpdateTask } from "../VoxelUpdateTask.js";
3
+ import { RGBUpdate } from "../Propagation/Illumanation/RGBUpdate.js";
4
+ import { SunUpdate } from "../Propagation/Illumanation/SunUpdate.js";
6
5
  import { FlowUpdate } from "../Propagation/Flow/FlowUpdate.js";
7
- import { FlowRemove } from "../Propagation/Flow/FlowRemove.js";
8
- const tasks = new UpdateTask();
9
- const updateLightTask = (tasks) => {
10
- let doRGB = ES.doRGBPropagation;
11
- let doSun = ES.doSunPropagation;
12
- const [dimension, x, y, z] = tasks.origin;
13
- tasks.nDataCursor.setFocalPoint(dimension, x, y, z);
14
- for (const n of $3dCardinalNeighbors) {
15
- const nx = n[0] + x;
16
- const ny = n[1] + y;
17
- const nz = n[2] + z;
18
- const nVoxel = tasks.nDataCursor.getVoxel(nx, ny, nz);
19
- if (!nVoxel)
20
- continue;
21
- if (doRGB) {
22
- if (nVoxel.hasRGBLight()) {
23
- tasks.rgb.update.push(nx, ny, nz);
24
- }
25
- }
26
- if (doSun) {
27
- if (nVoxel.hasSunLight()) {
28
- tasks.sun.update.push(nx, ny, nz);
29
- }
30
- }
31
- }
32
- };
33
- export async function EreaseAndUpdate(location) {
34
- const [dimension, x, y, z] = location;
35
- tasks.setOrigin(location);
36
- let voxel = tasks.sDataCursor.getVoxel(x, y, z);
37
- if (!voxel)
38
- return false;
39
- const substanceData = voxel.getSubstanceData();
40
- if (!voxel.isAir() && ES.doFlow && voxel.isRenderable()) {
41
- if (substanceData["dve_is_liquid"]) {
42
- FlowRemove(tasks);
43
- return tasks;
44
- }
45
- }
46
- voxel = tasks.sDataCursor.getVoxel(x, y, z);
47
- const light = voxel.getLight();
48
- const isLightSource = voxel.isLightSource();
49
- voxel.setSecondary(true).setId(0).setSecondary(false);
50
- voxel
51
- .setLight(light > 0 ? light : 0)
52
- .setId(0)
53
- .setLevel(0)
54
- .setLevelState(0)
55
- .setState(0)
56
- .setMod(0)
57
- .updateVoxel(1);
58
- if (ES.doLight) {
59
- if (ES.doRGBPropagation && isLightSource) {
60
- tasks.rgb.remove.push(x, y, z);
61
- RGBRemove(tasks);
62
- }
63
- updateLightTask(tasks);
64
- if (ES.doRGBPropagation) {
65
- RGBUpdate(tasks);
66
- }
67
- if (ES.doSunPropagation) {
68
- SunUpdate(tasks);
69
- }
70
- }
71
- tasks.bounds.update(x, y, z);
72
- tasks.bounds.update(x + 1, y + 1, z + 1);
73
- for (let i = 0; i < $3dCardinalNeighbors.length; i++) {
74
- tasks.sDataCursor
75
- .getVoxel($3dCardinalNeighbors[i][0] + x, $3dCardinalNeighbors[i][1] + y, $3dCardinalNeighbors[i][2] + z)
76
- ?.updateVoxel(2);
77
- }
78
- return tasks;
79
- }
80
- export async function PaintAndUpdate(data) {
81
- const [dimension, x, y, z] = data[0];
82
- tasks.setOrigin(data[0]);
83
- let voxel = tasks.sDataCursor.getVoxel(x, y, z);
84
- if (!voxel)
85
- return false;
86
- const raw = data[1];
87
- const isOpaque = voxel.isOpaque();
88
- let doRGB = ES.doRGBPropagation;
89
- let doSun = ES.doSunPropagation;
90
- lighttest: if (ES.doLight) {
91
- const light = voxel.getLight();
92
- if (light <= 0)
93
- break lighttest;
94
- if (doSun) {
95
- if (voxel.hasSunLight()) {
96
- tasks.sun.remove.push(x, y, z);
97
- SunRemove(tasks);
98
- }
99
- }
100
- if (doRGB) {
101
- if (voxel.hasRGBLight() && isOpaque) {
102
- tasks.rgb.remove.push(x, y, z);
103
- RGBRemove(tasks);
104
- }
105
- }
106
- }
107
- voxel = tasks.sDataCursor.getVoxel(x, y, z);
108
- const id = raw[0];
109
- if (id < 0)
110
- return false;
111
- voxel.setId(id);
112
- voxel.setLevel(raw[2]);
113
- voxel.setState(raw[3]);
114
- voxel.setMod(raw[4]);
115
- voxel.process();
116
- if (raw[3] > 0 && voxel.canHaveSecondaryVoxel()) {
117
- voxel.setSecondary(true);
118
- voxel.setId(raw[5]);
119
- voxel.setSecondary(false);
120
- }
121
- if (voxel.isLightSource() && voxel.getLightSourceValue()) {
122
- voxel.setLight(voxel.getLightSourceValue());
123
- }
124
- voxel.updateVoxel(0);
125
- if (ES.doLight) {
126
- updateLightTask(tasks);
127
- if (doRGB) {
128
- tasks.rgb.update.push(x, y, z);
129
- RGBUpdate(tasks);
130
- }
131
- if (doSun) {
132
- SunUpdate(tasks);
133
- }
134
- }
135
- voxel = tasks.sDataCursor.getVoxel(x, y, z);
136
- if (ES.doFlow) {
137
- if (!voxel.isAir() && voxel.getSubstanceData()["dve_is_liquid"]) {
138
- FlowUpdate(tasks);
139
- }
140
- }
141
- tasks.bounds.update(x, y, z);
142
- tasks.bounds.update(x + 1, y + 1, z + 1);
143
- for (let i = 0; i < $3dCardinalNeighbors.length; i++) {
144
- tasks.sDataCursor
145
- .getVoxel($3dCardinalNeighbors[i][0] + x, $3dCardinalNeighbors[i][1] + y, $3dCardinalNeighbors[i][2] + z)
146
- ?.updateVoxel(2);
147
- }
148
- return tasks;
149
- }
6
+ import { updateLightTask } from "./Common.js";
7
+ const tasks = new VoxelUpdateTask();
150
8
  export async function VoxelUpdate(data) {
151
9
  const [dimension, x, y, z] = data[0];
152
10
  tasks.setOrigin(data[0]);
@@ -1,6 +1,6 @@
1
- import { WorldCursor } from "../../World/Cursor/WorldCursor";
1
+ import { WorldCursor } from "../World/Cursor/WorldCursor";
2
2
  import { Vec3Array, Vector3Like } from "@amodx/math";
3
- import { LocationData } from "../../Math";
3
+ import { LocationData } from "../Math";
4
4
  export declare class TaskMap {
5
5
  _map: boolean[];
6
6
  get size(): number;
@@ -12,20 +12,21 @@ export declare class TaskMap {
12
12
  clear(): void;
13
13
  }
14
14
  declare class UpdatedBounds {
15
- _task: UpdateTask;
15
+ _task: VoxelUpdateTask;
16
16
  min: Vector3Like;
17
17
  max: Vector3Like;
18
- dimension: string;
19
- constructor(_task: UpdateTask);
20
- start(dimension?: string): void;
18
+ dimension: number;
19
+ constructor(_task: VoxelUpdateTask);
20
+ start(dimension?: number): void;
21
21
  update(x: number, y: number, z: number): void;
22
22
  getSections(): Vec3Array[];
23
23
  markSectionsAsDirty(): void;
24
24
  }
25
- export declare class UpdateTask {
25
+ export declare class VoxelUpdateTask {
26
26
  flow: FlowQueues;
27
27
  rgb: LightQueue;
28
28
  sun: LightQueue;
29
+ power: PowerQueue;
29
30
  bounds: UpdatedBounds;
30
31
  sDataCursor: WorldCursor;
31
32
  nDataCursor: WorldCursor;
@@ -52,4 +53,11 @@ declare class LightQueue {
52
53
  updateMap: TaskMap;
53
54
  clear(): void;
54
55
  }
56
+ declare class PowerQueue {
57
+ update: number[];
58
+ remove: number[];
59
+ removeMap: TaskMap;
60
+ updateMap: TaskMap;
61
+ clear(): void;
62
+ }
55
63
  export {};
@@ -1,7 +1,7 @@
1
- import { WorldCursor } from "../../World/Cursor/WorldCursor";
1
+ import { WorldCursor } from "../World/Cursor/WorldCursor";
2
2
  import { Vector3Like } from "@amodx/math";
3
- import { WorldSpaces } from "../../World/WorldSpaces";
4
- import { WorldRegister } from "../../World/WorldRegister";
3
+ import { WorldSpaces } from "../World/WorldSpaces";
4
+ import { WorldRegister } from "../World/WorldRegister";
5
5
  export class TaskMap {
6
6
  _map = [];
7
7
  get size() {
@@ -35,12 +35,12 @@ class UpdatedBounds {
35
35
  _task;
36
36
  min = Vector3Like.Clone(InfinityVec3);
37
37
  max = Vector3Like.Clone(NegativeInfinityVec3);
38
- dimension = "main";
38
+ dimension = 0;
39
39
  constructor(_task) {
40
40
  this._task = _task;
41
41
  }
42
42
  start(dimension) {
43
- this.dimension = dimension || "main";
43
+ this.dimension = dimension || 0;
44
44
  Vector3Like.Copy(this.min, InfinityVec3);
45
45
  Vector3Like.Copy(this.max, NegativeInfinityVec3);
46
46
  }
@@ -97,16 +97,17 @@ class UpdatedBounds {
97
97
  if (!sector)
98
98
  continue;
99
99
  const section = sector.getSection(x, y, z);
100
- section.setDirty(true);
100
+ section.setDisplayDirty(true);
101
101
  }
102
102
  }
103
103
  }
104
104
  }
105
105
  }
106
- export class UpdateTask {
106
+ export class VoxelUpdateTask {
107
107
  flow = new FlowQueues();
108
108
  rgb = new LightQueue();
109
109
  sun = new LightQueue();
110
+ power = new PowerQueue();
110
111
  bounds = new UpdatedBounds(this);
111
112
  sDataCursor = new WorldCursor();
112
113
  nDataCursor = new WorldCursor();
@@ -161,3 +162,15 @@ class LightQueue {
161
162
  this.updateMap.clear();
162
163
  }
163
164
  }
165
+ class PowerQueue {
166
+ update = [];
167
+ remove = [];
168
+ removeMap = new TaskMap();
169
+ updateMap = new TaskMap();
170
+ clear() {
171
+ this.update.length = 0;
172
+ this.remove.length = 0;
173
+ this.removeMap.clear();
174
+ this.updateMap.clear();
175
+ }
176
+ }
@@ -1,11 +1,11 @@
1
1
  import type { Vec3Array } from "@amodx/math";
2
2
  import { BrushTool } from "../../Tools/Brush/Brush.js";
3
- import { UpdateTask } from "../Update/UpdateTask.js";
3
+ import { VoxelUpdateTask } from "../VoxelUpdateTask.js";
4
4
  export declare class WorldGenBrush extends BrushTool {
5
5
  constructor();
6
6
  requestsId: "";
7
- tasks: UpdateTask;
8
- start(dimension: string, x: number, y: number, z: number): this;
7
+ tasks: VoxelUpdateTask;
8
+ start(dimension: number, x: number, y: number, z: number): this;
9
9
  paint(): this;
10
10
  getUpdatedSections(): Vec3Array[];
11
11
  update(): false | undefined;
@@ -3,7 +3,7 @@ import { BrushTool } from "../../Tools/Brush/Brush.js";
3
3
  import { VoxelLightData } from "../../Voxels/Cursor/VoxelLightData.js";
4
4
  import { WorldGeneration } from "./WorldGeneration.js";
5
5
  import { DivineVoxelEngineConstructor } from "../../Contexts/Constructor/DivineVoxelEngineConstructor.js";
6
- import { UpdateTask } from "../Update/UpdateTask.js";
6
+ import { VoxelUpdateTask } from "../VoxelUpdateTask.js";
7
7
  import { RGBRemove, RGBUpdate } from "../Propagation/Illumanation/RGBUpdate.js";
8
8
  import { SunRemove, SunUpdate } from "../Propagation/Illumanation/SunUpdate.js";
9
9
  const lightData = new VoxelLightData();
@@ -13,7 +13,7 @@ export class WorldGenBrush extends BrushTool {
13
13
  WorldGeneration._brushes.push(this);
14
14
  }
15
15
  requestsId;
16
- tasks = new UpdateTask();
16
+ tasks = new VoxelUpdateTask();
17
17
  start(dimension, x, y, z) {
18
18
  this.dataCursor.setFocalPoint(dimension, x, y, z);
19
19
  this.tasks.setOrigin([dimension, x, y, z]);
@@ -4,7 +4,7 @@ export declare class WorldGenRegister {
4
4
  static MAX_ATTEMPTS: number;
5
5
  static _requests: Map<string, {
6
6
  attempts: number;
7
- dimension: string;
7
+ dimension: number;
8
8
  sections: Map<string, [x: number, y: number, z: number]>;
9
9
  voxels: [x: number, y: number, z: number, data: RawVoxelData][];
10
10
  }>;
@@ -1,3 +1,3 @@
1
1
  import { Vec3Array } from "@amodx/math";
2
2
  import { VoxelTemplate } from "../VoxelTemplate";
3
- export default function CreateTemplate(dimension: string, start: Vec3Array, end: Vec3Array): VoxelTemplate;
3
+ export default function CreateTemplate(dimension: number, start: Vec3Array, end: Vec3Array): VoxelTemplate;
@@ -1,7 +1,7 @@
1
1
  import { BrushTool } from "./Brush.js";
2
2
  export class AdvancedBrush extends BrushTool {
3
3
  tasks;
4
- _location = ["main", 0, 0, 0];
4
+ _location = [0, 0, 0, 0];
5
5
  constructor(tasks) {
6
6
  super();
7
7
  this.tasks = tasks;
@@ -3,7 +3,7 @@ import { WorldCursor } from "../../World/Cursor/WorldCursor.js";
3
3
  import { VoxelCursor } from "../../Voxels/Cursor/VoxelCursor.js";
4
4
  export declare class BrushTool {
5
5
  data: PaintVoxelData;
6
- dimension: string;
6
+ dimension: number;
7
7
  x: number;
8
8
  y: number;
9
9
  z: number;
@@ -29,6 +29,6 @@ export declare class BrushTool {
29
29
  _erase(): void;
30
30
  paint(): this;
31
31
  erase(): this;
32
- start(dimension: string, x: number, y: number, z: number): this;
32
+ start(dimension: number, x: number, y: number, z: number): this;
33
33
  stop(): this;
34
34
  }
@@ -15,7 +15,7 @@ export class BrushTool {
15
15
  levelState: 0,
16
16
  mod: 0,
17
17
  };
18
- dimension = "main";
18
+ dimension = 0;
19
19
  x = 0;
20
20
  y = 0;
21
21
  z = 0;
@@ -24,6 +24,7 @@ declare class VoxelTasks {
24
24
  update: TaskToolTask<VoxelUpdateTasks>;
25
25
  paint: TaskToolTask<VoxelUpdateTasks>;
26
26
  erease: TaskToolTask<LocationData>;
27
+ logic: TaskToolTask<LocationData>;
27
28
  constructor(tool: TaskTool);
28
29
  }
29
30
  declare class BuildTask {
@@ -62,11 +62,13 @@ class VoxelTasks {
62
62
  update;
63
63
  paint;
64
64
  erease;
65
+ logic;
65
66
  constructor(tool) {
66
67
  this.tool = tool;
67
68
  this.update = new TaskToolTask(TasksIds.VoxelUpdate, tool.threads);
68
69
  this.paint = new TaskToolTask(TasksIds.VoxelPaint, tool.threads);
69
70
  this.erease = new TaskToolTask(TasksIds.VoxelErease, tool.threads);
71
+ this.logic = new TaskToolTask(TasksIds.LogicUpdate, tool.threads);
70
72
  }
71
73
  }
72
74
  class BuildTask {
@@ -1,17 +1,22 @@
1
- export type BinaryBufferTypes =
2
- /**If the buffer compressed to a single value the type will be a vlaue */
3
- "value" | "1-bit" | "2-bit" | "4-bit" | "8-bit" | "16-bit";
1
+ export declare enum BinaryBufferTypes {
2
+ Value = 0,
3
+ BitArray = 1,
4
+ HalfNibbleArray = 2,
5
+ NibbleArray = 4,
6
+ ByteArray = 8,
7
+ ShortArray = 16
8
+ }
4
9
  export interface BinaryBufferData {
5
- type?: BinaryBufferTypes;
6
- buffer: number | Uint8Array | Uint16Array;
10
+ type: BinaryBufferTypes;
11
+ buffer: number | ArrayBufferLike;
7
12
  }
8
13
  export interface BinaryBuffer extends BinaryBufferData {
9
14
  }
10
15
  export declare class BinaryBuffer {
11
- static BytePaletteMax: number;
12
- static NibblePaletteMax: number;
13
- static HalfNibblePaletteMax: number;
14
- static BitPaletteMax: number;
16
+ static ByteArrayMax: number;
17
+ static NibbleArrayMax: number;
18
+ static HalfNibbleArrayMax: number;
19
+ static BitArrayMax: number;
15
20
  static DetermineSubByteArray: (paletteSize: number) => BinaryBufferTypes | null;
16
21
  static CreateBufferForType(type: BinaryBufferTypes, length: number): Uint16Array | Uint8Array;
17
22
  static GetConvertedBufferSize(source: Uint8Array | Uint16Array, type: BinaryBufferTypes): number;
@@ -20,10 +25,11 @@ export declare class BinaryBuffer {
20
25
  static SetBufferAtIndex(source: Uint8Array | Uint16Array, type: BinaryBufferTypes, index: number, value: number): number | void;
21
26
  static Convert(source: Uint8Array | Uint16Array, sourceType: BinaryBufferTypes, destinationType: BinaryBufferTypes): Uint16Array | Uint8Array;
22
27
  static Create(data: Partial<BinaryBufferData>): BinaryBufferData;
28
+ bufferView: Uint8Array | Uint16Array;
23
29
  constructor(data: BinaryBufferData);
24
30
  getValue(index: number): number;
25
31
  toJSON(): {
26
- type?: BinaryBufferTypes | undefined;
27
- buffer: number | Uint16Array | Uint8Array;
32
+ buffer: number | ArrayBufferLike;
33
+ type: BinaryBufferTypes;
28
34
  };
29
35
  }