@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
@@ -1,13 +1,14 @@
1
1
  import { MeshRegister } from "./MeshRegister.js";
2
- import { VoxelEffectRegister } from "../Voxels/Effects/VoxelEffectRegister.js";
2
+ import { CompactedSectionVoxelMesh, } from "../Mesher/Geomtry/CompactedSectionVoxelMesh";
3
3
  const added = new Set();
4
+ const compacted = new CompactedSectionVoxelMesh();
5
+ const location = [0, 0, 0, 0];
4
6
  export class MeshManager {
5
7
  static sectorMeshes;
6
8
  static runningUpdate = false;
7
9
  static updateSection(data) {
8
- const location = data[0];
9
- const sections = data[1];
10
- const effects = data[2];
10
+ compacted.setData(data);
11
+ compacted.getLocation(location);
11
12
  let sector = MeshRegister.sectors.get(location);
12
13
  if (!sector) {
13
14
  sector = MeshRegister.sectors.add(location);
@@ -16,30 +17,30 @@ export class MeshManager {
16
17
  if (!section) {
17
18
  section = sector.addSection(location[1], location[2], location[3]);
18
19
  }
20
+ /*
19
21
  added.clear();
20
22
  for (const [id, points] of effects) {
21
- added.add(id);
22
- if (!section.effects.has(id)) {
23
- const EffectClass = VoxelEffectRegister.get(id);
24
- const newEffect = new EffectClass(section);
25
- newEffect.init();
26
- newEffect.setPoints(points);
27
- section.effects.set(id, newEffect);
28
- }
29
- else {
30
- const effect = section.effects.get(id);
31
- effect.setPoints(points);
32
- }
23
+ added.add(id);
24
+ if (!section.effects.has(id)) {
25
+ const EffectClass = VoxelEffectRegister.get(id);
26
+ const newEffect = new EffectClass(section);
27
+ newEffect.init();
28
+ newEffect.setPoints(points);
29
+ section.effects.set(id, newEffect);
30
+ } else {
31
+ const effect = section.effects.get(id)!;
32
+ effect.setPoints(points);
33
+ }
33
34
  }
34
35
  for (const [key, effect] of section.effects) {
35
- if (!added.has(key)) {
36
- effect.dispose();
37
- section.effects.delete(key);
38
- }
39
- }
40
- if (sections[0] == 0) {
41
- this.sectorMeshes.updateVertexData(section, [location[1], location[2], location[3]], sections);
36
+ if (!added.has(key)) {
37
+ effect.dispose();
38
+ section.effects.delete(key);
39
+ }
42
40
  }
41
+
42
+ */
43
+ this.sectorMeshes.updateVertexData(section, compacted);
43
44
  }
44
45
  static removeSector(data) {
45
46
  const sector = MeshRegister.sectors.remove(data);
@@ -1,16 +1,16 @@
1
1
  import { type LocationData } from "../Math/index.js";
2
2
  import { SectorMesh } from "./Classes/SectorMesh.js";
3
- export type MeshRegisterDimensions = Map<string, Map<string, SectorMesh>>;
3
+ export type MeshRegisterDimensions = Map<number, Map<string, SectorMesh>>;
4
4
  declare class Sectors {
5
5
  static add(location: LocationData): SectorMesh;
6
6
  static remove(location: LocationData): false | SectorMesh;
7
7
  static get(location: LocationData): false | SectorMesh | undefined;
8
8
  }
9
9
  declare class Dimensions {
10
- static add(id: string): Map<any, any>;
11
- static get(id: string): Map<string, SectorMesh> | undefined;
12
- static getAllMeshes(id: string): Generator<[location: LocationData, substance: string, mesh: any]>;
13
- static remove(id: string): boolean;
10
+ static add(id: number): Map<any, any>;
11
+ static get(id: number): Map<string, SectorMesh> | undefined;
12
+ static getAllMeshes(id: number): Generator<[location: LocationData, substance: string, mesh: any]>;
13
+ static remove(id: number): boolean;
14
14
  }
15
15
  export declare class MeshRegister {
16
16
  static _dimensions: MeshRegisterDimensions;
@@ -79,7 +79,7 @@ class Dimensions {
79
79
  }
80
80
  }
81
81
  export class MeshRegister {
82
- static _dimensions = new Map([["main", new Map()]]);
82
+ static _dimensions = new Map([[0, new Map()]]);
83
83
  static dimensions = Dimensions;
84
84
  static sectors = Sectors;
85
85
  static clearAll() {
@@ -87,7 +87,7 @@ export class MeshRegister {
87
87
  this.dimensions.remove(dkey);
88
88
  }
89
89
  this._dimensions.clear();
90
- this._dimensions.set("main", new Map());
90
+ this._dimensions.set(0, new Map());
91
91
  }
92
92
  }
93
93
  window.MeshRegister = MeshRegister;
@@ -17,6 +17,7 @@ declare class EngineSettingsClass extends TypedEventTarget<EngineSettingsEvents>
17
17
  get doRGBPropagation(): boolean;
18
18
  get doLight(): boolean;
19
19
  get doFlow(): boolean;
20
+ get doPower(): boolean;
20
21
  getSettings(): EngineSettingsData;
21
22
  syncSettings(data: EngineSettingsData): void;
22
23
  getSettingsCopy(): any;
@@ -10,16 +10,19 @@ class EngineSettingsClass extends TypedEventTarget {
10
10
  settings = new EngineSettingsData();
11
11
  version = "0.0.72";
12
12
  get doSunPropagation() {
13
- return this.settings.lighting.sunLightEnabled == true;
13
+ return this.settings.propagation.sunLightEnabled == true;
14
14
  }
15
15
  get doRGBPropagation() {
16
- return this.settings.lighting.rgbLightEnabled == true;
16
+ return this.settings.propagation.rgbLightEnabled == true;
17
17
  }
18
18
  get doLight() {
19
19
  return this.doRGBPropagation || this.doSunPropagation;
20
20
  }
21
21
  get doFlow() {
22
- return this.settings.flow.enable;
22
+ return this.settings.propagation.flowEnabled;
23
+ }
24
+ get doPower() {
25
+ return this.settings.propagation.powerEnabled;
23
26
  }
24
27
  getSettings() {
25
28
  return this.settings;
@@ -29,35 +29,21 @@ export interface WorldSettings {
29
29
  export declare class WorldSettings {
30
30
  min: Vector3Like;
31
31
  max: Vector3Like;
32
+ sectorPower2Size: Vector3Like;
33
+ sectionPower2Size: Vector3Like;
32
34
  }
33
- export interface SectorSettings {
35
+ export interface PropagationSettings {
34
36
  }
35
- export declare class SectorSettings {
36
- power2Size: Vector3Like;
37
- }
38
- export interface SectionSettings {
39
- }
40
- export declare class SectionSettings {
41
- power2Size: Vector3Like;
42
- }
43
- export interface FlowSettings {
44
- }
45
- export declare class FlowSettings {
46
- enable: boolean;
47
- }
48
- export interface LightingSettings {
49
- }
50
- export declare class LightingSettings {
37
+ export declare class PropagationSettings {
51
38
  rgbLightEnabled: boolean;
52
39
  sunLightEnabled: boolean;
40
+ flowEnabled: boolean;
41
+ powerEnabled: boolean;
53
42
  }
54
43
  export declare class EngineSettingsData {
55
44
  mesher: MesherSettingsData;
56
45
  rendererSettings: RenderSettingsData;
57
46
  updating: UpdatingSettings;
58
47
  world: WorldSettings;
59
- sectors: SectorSettings;
60
- sections: SectionSettings;
61
- flow: FlowSettings;
62
- lighting: LightingSettings;
48
+ propagation: PropagationSettings;
63
49
  }
@@ -21,27 +21,19 @@ export class UpdatingSettings {
21
21
  export class WorldSettings {
22
22
  min = Vector3Like.Create(-Number.MAX_SAFE_INTEGER, 0, -Number.MAX_SAFE_INTEGER);
23
23
  max = Vector3Like.Create(Number.MAX_SAFE_INTEGER, 256, Number.MAX_SAFE_INTEGER);
24
+ sectorPower2Size = Vector3Like.Create(4, 8, 4);
25
+ sectionPower2Size = Vector3Like.Create(4, 4, 4);
24
26
  }
25
- export class SectorSettings {
26
- power2Size = Vector3Like.Create(4, 8, 4);
27
- }
28
- export class SectionSettings {
29
- power2Size = Vector3Like.Create(4, 4, 4);
30
- }
31
- export class FlowSettings {
32
- enable = true;
33
- }
34
- export class LightingSettings {
27
+ export class PropagationSettings {
35
28
  rgbLightEnabled = true;
36
29
  sunLightEnabled = true;
30
+ flowEnabled = true;
31
+ powerEnabled = true;
37
32
  }
38
33
  export class EngineSettingsData {
39
34
  mesher = new MesherSettingsData();
40
35
  rendererSettings = new RenderSettingsData();
41
36
  updating = new UpdatingSettings();
42
37
  world = new WorldSettings();
43
- sectors = new SectorSettings();
44
- sections = new SectionSettings();
45
- flow = new FlowSettings();
46
- lighting = new LightingSettings();
38
+ propagation = new PropagationSettings();
47
39
  }
@@ -0,0 +1 @@
1
+ export default function (): void;
@@ -0,0 +1,10 @@
1
+ import { Threads } from "@amodx/threads";
2
+ import { TasksIds } from "../TasksIds";
3
+ import { VoxelUpdateTask } from "../VoxelUpdateTask";
4
+ import { VoxelLogicUpdate } from "./VoxelLogicUpdate";
5
+ export default function () {
6
+ const tasks = new VoxelUpdateTask();
7
+ Threads.registerTask(TasksIds.LogicUpdate, async (data, origin) => {
8
+ VoxelLogicUpdate(tasks, data);
9
+ });
10
+ }
@@ -0,0 +1,3 @@
1
+ import { LocationData } from "../../Math";
2
+ import { VoxelUpdateTask } from "../../Tasks/VoxelUpdateTask";
3
+ export declare function VoxelLogicUpdate(task: VoxelUpdateTask, location: LocationData): false | undefined;
@@ -0,0 +1,71 @@
1
+ import { WorldRegister } from "../../World/WorldRegister";
2
+ import { WorldSpaces } from "../../World/WorldSpaces";
3
+ import { SectionCursor } from "../../World/Cursor/SectionCursor";
4
+ import { VoxelLogicRegister } from "../../Voxels/Logic/VoxelLogicRegister";
5
+ import { VoxelTagIds } from "../../Voxels/Data/VoxelTag.types";
6
+ import { RGBRemove, RGBUpdate } from "../../Tasks/Propagation";
7
+ import { $3dCardinalNeighbors } from "../../Math/CardinalNeighbors";
8
+ const sectionCursor = new SectionCursor();
9
+ export function VoxelLogicUpdate(task, location) {
10
+ task.setOrigin(location);
11
+ const sector = WorldRegister.sectors.getAt(location);
12
+ if (!sector) {
13
+ console.warn(`Could not run logic update sector at ${location} does not exist`);
14
+ return false;
15
+ }
16
+ const section = sector.getSection(location[1], location[2], location[3]);
17
+ if (!section) {
18
+ console.warn(`Could not run logic update sector at ${location}. Section does not exist`);
19
+ return false;
20
+ }
21
+ const [minY, maxY] = section.getLogicMinMax();
22
+ const [cx, cy, cz] = section.position;
23
+ const slice = WorldSpaces.section.bounds.x * WorldSpaces.section.bounds.z;
24
+ const startY = minY * slice;
25
+ const endY = (maxY + 1) * slice;
26
+ sectionCursor.setSection(section);
27
+ for (let i = startY; i < endY; i++) {
28
+ if (!(i % slice)) {
29
+ const y = i / slice;
30
+ if (!section.isLogicSliceDirty(y)) {
31
+ i += slice - 1;
32
+ continue;
33
+ }
34
+ }
35
+ if (!section.ids[i] || !section.getVoxelLogicDirty(i))
36
+ continue;
37
+ const voxel = sectionCursor.getVoxelAtIndex(i);
38
+ const x = cx + sectionCursor._voxelPosition.x;
39
+ const y = cy + sectionCursor._voxelPosition.y;
40
+ const z = cz + sectionCursor._voxelPosition.z;
41
+ const logic = VoxelLogicRegister.voxels[section.ids[i]];
42
+ if (!logic)
43
+ continue;
44
+ if (logic.hasTag(VoxelTagIds.isLightSource)) {
45
+ const lightSource = logic.getTagValue(VoxelTagIds.isLightSource, voxel);
46
+ if (lightSource) {
47
+ task.rgb.update.push(x, y, z);
48
+ }
49
+ else {
50
+ for (const n of $3dCardinalNeighbors) {
51
+ const nx = n[0] + x;
52
+ const ny = n[1] + y;
53
+ const nz = n[2] + z;
54
+ const nVoxel = task.nDataCursor.getVoxel(nx, ny, nz);
55
+ if (!nVoxel)
56
+ continue;
57
+ if (nVoxel.hasRGBLight()) {
58
+ task.rgb.remove.push(nx, ny, nz);
59
+ }
60
+ }
61
+ }
62
+ }
63
+ }
64
+ RGBRemove(task);
65
+ RGBUpdate(task);
66
+ section.logicDirtyMap.fill(0);
67
+ section.logicDirty.fill(0);
68
+ section.setLogicDirty(false);
69
+ section.setLogicUpdateInProgress(false);
70
+ task.bounds.markSectionsAsDirty();
71
+ }
@@ -1,4 +1,4 @@
1
- import { UpdateTask } from "../../Update/UpdateTask.js";
1
+ import { VoxelUpdateTask } from "../../VoxelUpdateTask.js";
2
2
  export declare const ExplosionManager: {
3
- runExplosion(tasks: UpdateTask, radius: number): void;
3
+ runExplosion(tasks: VoxelUpdateTask, radius: number): void;
4
4
  };
@@ -5,14 +5,13 @@ import { $3dCardinalNeighbors } from "../../../Math/CardinalNeighbors.js";
5
5
  import { Distance3D } from "@amodx/math/Vectors/Functions/Distance3d";
6
6
  import { RGBRemove, RGBUpdate } from "../Illumanation/RGBUpdate.js";
7
7
  import { SunRemove, SunUpdate } from "../Illumanation/SunUpdate.js";
8
- import { FlowManager } from "../Flow/FlowManager.js";
9
8
  import { VisitedMap } from "../../../Util/VisistedMap";
10
9
  import { VoxelLightData } from "../../../Voxels/Cursor/VoxelLightData.js";
11
10
  const lightData = new VoxelLightData();
12
11
  export const ExplosionManager = {
13
12
  runExplosion(tasks, radius) {
14
13
  const [dimension, sx, sy, sz] = tasks.origin;
15
- FlowManager.setDimension(dimension);
14
+ // FlowManager.setDimension(dimension);
16
15
  const queue = [];
17
16
  const map = new VisitedMap();
18
17
  queue.push([sx, sy, sz]);
@@ -1,13 +1,13 @@
1
1
  import { BrushTool } from "../../../Tools/Brush/Brush.js";
2
- import { UpdateTask } from "../../Update/UpdateTask.js";
2
+ import { VoxelUpdateTask } from "../../VoxelUpdateTask.js";
3
3
  import { WorldCursor } from "../../../World/index.js";
4
4
  export declare class FlowManager {
5
5
  static _brush: BrushTool;
6
6
  static _sDataTool: WorldCursor;
7
7
  static _nDataTool: WorldCursor;
8
- static setVoxel(tasks: UpdateTask, vox: string, level: number, levelState: number, x: number, y: number, z: number): void;
8
+ static setVoxel(tasks: VoxelUpdateTask, vox: string, level: number, levelState: number, x: number, y: number, z: number): void;
9
9
  static setDimension(dimension: string): void;
10
- static removeVoxel(tasks: UpdateTask, x: number, y: number, z: number): void;
10
+ static removeVoxel(tasks: VoxelUpdateTask, x: number, y: number, z: number): void;
11
11
  static getFlowRate(substance: string): number;
12
12
  static getVoxel(x: number, y: number, z: number): WorldCursor;
13
13
  static setLevel(level: number, x: number, y: number, z: number): void;
@@ -18,5 +18,5 @@ export declare class FlowManager {
18
18
  static wait(ms: number): Promise<unknown>;
19
19
  static _lightValues: [s: number, r: number, g: number, b: number];
20
20
  static getAbsorbLight(x: number, y: number, z: number): void;
21
- static sunCheck(tasks: UpdateTask, x: number, y: number, z: number): void;
21
+ static sunCheck(tasks: VoxelUpdateTask, x: number, y: number, z: number): void;
22
22
  }
@@ -1,2 +1,2 @@
1
- import { UpdateTask } from "../../Update/UpdateTask.js";
2
- export declare function FlowRemove(tasks: UpdateTask): Promise<void>;
1
+ import { VoxelUpdateTask } from "../../VoxelUpdateTask.js";
2
+ export declare function FlowRemove(tasks: VoxelUpdateTask): Promise<void>;
@@ -1,2 +1,2 @@
1
- import { UpdateTask } from "../../Update/UpdateTask.js";
2
- export declare function FlowUpdate(tasks: UpdateTask, rebuild?: boolean): Promise<void>;
1
+ import { VoxelUpdateTask } from "../../VoxelUpdateTask.js";
2
+ export declare function FlowUpdate(tasks: VoxelUpdateTask, rebuild?: boolean): Promise<void>;
@@ -1,2 +1,2 @@
1
- import { UpdateTask } from "../../../Tasks/Update/UpdateTask";
2
- export declare function WorldFlow(task: UpdateTask): false | undefined;
1
+ import { VoxelUpdateTask } from "../../VoxelUpdateTask";
2
+ export declare function WorldFlow(task: VoxelUpdateTask): false | undefined;
@@ -1,3 +1,3 @@
1
- import { UpdateTask } from "../../Update/UpdateTask";
2
- export declare function RGBUpdate(tasks: UpdateTask): void;
3
- export declare function RGBRemove(tasks: UpdateTask): void;
1
+ import { VoxelUpdateTask } from "../../VoxelUpdateTask";
2
+ export declare function RGBUpdate(tasks: VoxelUpdateTask): void;
3
+ export declare function RGBRemove(tasks: VoxelUpdateTask): void;
@@ -1,3 +1,3 @@
1
- import { UpdateTask } from "../../Update/UpdateTask";
2
- export declare function SunUpdate(tasks: UpdateTask): void;
3
- export declare function SunRemove(tasks: UpdateTask, clearUpdateMap?: boolean): void;
1
+ import { VoxelUpdateTask } from "../../VoxelUpdateTask";
2
+ export declare function SunUpdate(tasks: VoxelUpdateTask): void;
3
+ export declare function SunRemove(tasks: VoxelUpdateTask, clearUpdateMap?: boolean): void;
@@ -1,2 +1,2 @@
1
- import { UpdateTask } from "../../../Tasks/Update/UpdateTask";
2
- export declare function WorldRGB(task: UpdateTask): false | undefined;
1
+ import { VoxelUpdateTask } from "../../VoxelUpdateTask";
2
+ export declare function WorldRGB(task: VoxelUpdateTask): false | undefined;
@@ -1,2 +1,2 @@
1
- import { UpdateTask } from "../../Update/UpdateTask.js";
2
- export declare function RunWorldSun(tasks: UpdateTask): void;
1
+ import { VoxelUpdateTask } from "../../VoxelUpdateTask.js";
2
+ export declare function RunWorldSun(tasks: VoxelUpdateTask): void;
@@ -1,5 +1,3 @@
1
- //types
2
- //data
3
1
  import { $3dCardinalNeighbors } from "../../../Math/CardinalNeighbors.js";
4
2
  import { WorldSpaces } from "../../../World/WorldSpaces.js";
5
3
  import { SectorHeightMap } from "../../../World/Sector/SectorHeightMap.js";
@@ -15,11 +13,11 @@ const FloodOutPositions = [
15
13
  const queue = [];
16
14
  const lightData = new VoxelLightData();
17
15
  export function RunWorldSun(tasks) {
18
- const [dimension, cx, cy, cz] = tasks.origin;
16
+ const [, cx, cy, cz] = tasks.origin;
19
17
  const RmaxY = SectorHeightMap.getRelative(tasks.origin);
20
18
  const AmaxY = SectorHeightMap.getAbsolute(tasks.origin);
21
19
  const maxX = cx + WorldSpaces.sector.bounds.x;
22
- const maxY = WorldSpaces.world.bounds.MaxY;
20
+ const maxY = cy + WorldSpaces.sector.bounds.y;
23
21
  const maxZ = cz + WorldSpaces.sector.bounds.z;
24
22
  const sectorCursor = tasks.nDataCursor.getSector(tasks.origin[1], tasks.origin[2], tasks.origin[3]);
25
23
  if (!sectorCursor) {
@@ -29,7 +27,7 @@ export function RunWorldSun(tasks) {
29
27
  const minY = AmaxY - 1 < 0 ? 0 : AmaxY;
30
28
  const section = sectorCursor.getSection(cx, minY, cz);
31
29
  const sectionY = section.getPosition()[1] + WorldSpaces.section.bounds.y;
32
- //fill
30
+ //fill to relative max y
33
31
  for (let iy = minY; iy < sectionY; iy++) {
34
32
  for (let ix = cx; ix < maxX; ix++) {
35
33
  for (let iz = cz; iz < maxZ; iz++) {
@@ -43,6 +41,7 @@ export function RunWorldSun(tasks) {
43
41
  }
44
42
  }
45
43
  }
44
+ //fill rest
46
45
  for (let iy = sectionY; iy < maxY; iy += WorldSpaces.section.bounds.y) {
47
46
  const section = sectorCursor.getSection(cx, iy, cz);
48
47
  const length = section.light.length;
@@ -50,9 +49,9 @@ export function RunWorldSun(tasks) {
50
49
  section.light[i] = lightData.setS(0xf, section.light[i]);
51
50
  }
52
51
  }
52
+ //accumulate
53
53
  const maxAcculamteY = AmaxY == RmaxY ? RmaxY + 1 : RmaxY;
54
54
  let index = queue.length;
55
- //accumulate
56
55
  for (let iy = minY; iy <= maxAcculamteY; iy++) {
57
56
  for (let ix = cx; ix < maxX; ix++) {
58
57
  for (let iz = cz; iz < maxZ; iz++) {
@@ -94,9 +93,7 @@ export function RunWorldSun(tasks) {
94
93
  if (nVoxel) {
95
94
  const nl = nVoxel.getLight();
96
95
  if (nl > -1 && isLessThanForSunAdd(nl, sl)) {
97
- queue.push(nx);
98
- queue.push(ny);
99
- queue.push(nz);
96
+ queue.push(nx, ny, nz);
100
97
  nVoxel.setLight(getMinusOneForSun(sl, nl));
101
98
  }
102
99
  }
@@ -106,16 +103,12 @@ export function RunWorldSun(tasks) {
106
103
  const nl = nVoxel.getLight();
107
104
  if (nl > -1 && isLessThanForSunAddDown(nl, sl)) {
108
105
  if (nVoxel.isAir()) {
109
- queue.push(x);
110
- queue.push(y - 1);
111
- queue.push(z);
106
+ queue.push(x, y - 1, z);
112
107
  nVoxel.setLight(getSunLightForUnderVoxel(sl, nl));
113
108
  }
114
109
  else {
115
110
  if (!nVoxel.isOpaque()) {
116
- queue.push(x);
117
- queue.push(y - 1);
118
- queue.push(z);
111
+ queue.push(x, y - 1, z);
119
112
  nVoxel.setLight(getMinusOneForSun(sl, nl));
120
113
  }
121
114
  }
@@ -1,13 +1,13 @@
1
1
  import { Threads } from "@amodx/threads";
2
2
  import { TasksIds } from "../TasksIds";
3
- import { UpdateTask } from "../Update/UpdateTask";
3
+ import { VoxelUpdateTask } from "../VoxelUpdateTask";
4
4
  import { WorldSpaces } from "../../World/WorldSpaces";
5
5
  import { RunWorldSun } from "./Illumanation/WorldSun";
6
6
  import { ExplosionManager } from "./Explosion/ExplosionManager";
7
7
  import { WorldRGB } from "./Illumanation/WorldRGB";
8
8
  export default function InitTasks() {
9
9
  Threads.registerTask(TasksIds.Propagation, async (location) => {
10
- const task = new UpdateTask();
10
+ const task = new VoxelUpdateTask();
11
11
  task.setOrigin(location);
12
12
  WorldRGB(task);
13
13
  // task.setOrigin(location);
@@ -16,7 +16,7 @@ export default function InitTasks() {
16
16
  Threads.registerTask(TasksIds.Explosion, async (data) => {
17
17
  const location = data[0];
18
18
  const sectorPosition = WorldSpaces.sector.getPosition(location[1], location[2], location[3]);
19
- const task = new UpdateTask();
19
+ const task = new VoxelUpdateTask();
20
20
  task.setOrigin([
21
21
  location[0],
22
22
  sectorPosition.x,
@@ -27,7 +27,7 @@ export default function InitTasks() {
27
27
  });
28
28
  Threads.registerTask(TasksIds.WorldSun, (location) => {
29
29
  const sectorPosition = WorldSpaces.sector.getPosition(location[1], location[2], location[3]);
30
- const task = new UpdateTask();
30
+ const task = new VoxelUpdateTask();
31
31
  task.setOrigin([
32
32
  location[0],
33
33
  sectorPosition.x,
@@ -0,0 +1,3 @@
1
+ import { VoxelUpdateTask } from "../../VoxelUpdateTask";
2
+ export declare function PowerUpdate(tasks: VoxelUpdateTask): void;
3
+ export declare function PowerRemove(tasks: VoxelUpdateTask): void;
@@ -0,0 +1,80 @@
1
+ import { $3dCardinalNeighbors } from "../../../Math/CardinalNeighbors";
2
+ //@todo change array to not use push and shift
3
+ export function PowerUpdate(tasks) {
4
+ const queue = tasks.power.update;
5
+ while (queue.length) {
6
+ const x = queue.shift();
7
+ const y = queue.shift();
8
+ const z = queue.shift();
9
+ const voxel = tasks.sDataCursor.getVoxel(x, y, z);
10
+ if (!voxel)
11
+ continue;
12
+ const sl = voxel.getPower();
13
+ if (sl <= 0)
14
+ continue;
15
+ for (let i = 0; i < 6; i++) {
16
+ const nx = $3dCardinalNeighbors[i][0] + x;
17
+ const ny = $3dCardinalNeighbors[i][1] + y;
18
+ const nz = $3dCardinalNeighbors[i][2] + z;
19
+ if (!tasks.nDataCursor.inBounds(nx, ny, nz))
20
+ continue;
21
+ const voxel = tasks.nDataCursor.getVoxel(nx, ny, nz);
22
+ if (!voxel)
23
+ continue;
24
+ const nl = voxel.getPower();
25
+ if (nl > -1 && nl < sl) {
26
+ if (voxel._tags["dve_can_carry_power"]) {
27
+ queue.push(nx, ny, nz);
28
+ }
29
+ voxel.setPower(sl - 1);
30
+ }
31
+ }
32
+ tasks.bounds.update(x, y, z);
33
+ }
34
+ }
35
+ export function PowerRemove(tasks) {
36
+ const remove = tasks.power.remove;
37
+ const update = tasks.power.update;
38
+ const removeMap = tasks.power.removeMap;
39
+ const updateMap = tasks.power.updateMap;
40
+ while (remove.length) {
41
+ const x = remove.shift();
42
+ const y = remove.shift();
43
+ const z = remove.shift();
44
+ if (removeMap.has(x, y, z))
45
+ continue;
46
+ removeMap.add(x, y, z);
47
+ const voxel = tasks.sDataCursor.getVoxel(x, y, z);
48
+ if (!voxel)
49
+ continue;
50
+ const sl = voxel.isAir() ? voxel.getLevel() : voxel.getPower();
51
+ if (sl <= 0)
52
+ continue;
53
+ for (let i = 0; i < 6; i++) {
54
+ const nx = $3dCardinalNeighbors[i][0] + x;
55
+ const ny = $3dCardinalNeighbors[i][1] + y;
56
+ const nz = $3dCardinalNeighbors[i][2] + z;
57
+ if (!tasks.nDataCursor.inBounds(nx, ny, nz))
58
+ continue;
59
+ const voxel = tasks.nDataCursor.getVoxel(nx, ny, nz);
60
+ if (!voxel)
61
+ continue;
62
+ const nl = voxel.isAir() ? voxel.getLevel() : voxel.getPower();
63
+ if (nl > 0 && nl < sl) {
64
+ remove.push(nx, ny, nz);
65
+ if (voxel.isPowerSource()) {
66
+ update.push(nx, ny, nz);
67
+ }
68
+ }
69
+ else {
70
+ if (nl > 0 && nl > sl && !updateMap.has(nx, ny, nz)) {
71
+ updateMap.add(nx, ny, nz);
72
+ update.push(nx, ny, nz);
73
+ }
74
+ }
75
+ }
76
+ tasks.bounds.update(x, y, z);
77
+ voxel.setPower(0);
78
+ }
79
+ removeMap.clear();
80
+ }
@@ -3,13 +3,13 @@ import type { Vec3Array } from "@amodx/math";
3
3
  import type { RawVoxelData } from "../Voxels/Types/Voxel.types.js";
4
4
  import { SectorData } from "World/index.js";
5
5
  export type WorldLockTasks = [
6
- dimension: string,
6
+ dimension: number,
7
7
  start: Vec3Array,
8
8
  end: Vec3Array
9
9
  ];
10
10
  export type VoxelUpdateTasks = [location: LocationData, raw: RawVoxelData];
11
11
  export type RunRebuildTasks = [buildQueue: string];
12
- export type RunBuildQueue = [dimension: string, sections: Vec3Array[]];
12
+ export type RunBuildQueue = [dimension: number, sections: Vec3Array[]];
13
13
  export type GenerateTasks = [location: LocationData, data: any];
14
14
  export type ExplosionTasks = [location: LocationData, radius: number];
15
15
  export type LoadSectorDataTasks = [location: LocationData, sector: SectorData];
@@ -17,5 +17,6 @@ export declare enum TasksIds {
17
17
  Explosion = 15,
18
18
  VoxelErease = 16,
19
19
  VoxelPaint = 17,
20
- VoxelUpdate = 18
20
+ VoxelUpdate = 18,
21
+ LogicUpdate = 19
21
22
  }
package/Tasks/TasksIds.js CHANGED
@@ -19,4 +19,5 @@ export var TasksIds;
19
19
  TasksIds[TasksIds["VoxelErease"] = 16] = "VoxelErease";
20
20
  TasksIds[TasksIds["VoxelPaint"] = 17] = "VoxelPaint";
21
21
  TasksIds[TasksIds["VoxelUpdate"] = 18] = "VoxelUpdate";
22
+ TasksIds[TasksIds["LogicUpdate"] = 19] = "LogicUpdate";
22
23
  })(TasksIds || (TasksIds = {}));
@@ -0,0 +1,3 @@
1
+ import { VoxelUpdateTask } from "../VoxelUpdateTask.js";
2
+ export declare const updateLightTask: (tasks: VoxelUpdateTask) => void;
3
+ export declare const updatePowerTask: (tasks: VoxelUpdateTask) => void;