@divinevoxel/vlox 0.0.72 → 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.
- package/Contexts/Base/Remote/InitDataSync.js +4 -0
- package/Contexts/Base/Remote/InitWorldDataSync.js +1 -1
- package/Contexts/Render/DivineVoxelEngineRender.d.ts +2 -1
- package/Contexts/World/DivineVoxelEngineWorld.d.ts +2 -1
- package/Init/StartConstructor.js +8 -4
- package/Init/StartWorld.d.ts +1 -1
- package/Math/index.d.ts +5 -1
- package/Mesher/Functions/CompactVoxelMesh.d.ts +2 -2
- package/Mesher/Functions/CompactVoxelMesh.js +1 -1
- package/Mesher/Functions/CompactVoxelSectionMesh.d.ts +4 -0
- package/Mesher/Functions/CompactVoxelSectionMesh.js +112 -0
- package/Mesher/Functions/MeshSection.d.ts +1 -1
- package/Mesher/Functions/MeshSection.js +27 -22
- package/Mesher/Functions/MeshTexture.d.ts +1 -1
- package/Mesher/Functions/MeshTexture.js +3 -4
- package/Mesher/Geomtry/CompactedSectionVoxelMesh.d.ts +23 -0
- package/Mesher/Geomtry/CompactedSectionVoxelMesh.js +144 -0
- package/Mesher/Geomtry/Primitives/QuadVertexData.d.ts +12 -10
- package/Mesher/Geomtry/Primitives/QuadVertexData.js +49 -56
- package/Mesher/Geomtry/VoxelGeometryBuilder.d.ts +2 -2
- package/Mesher/Geomtry/VoxelGeometryBuilder.js +120 -199
- package/Mesher/Geomtry/VoxelMesh.d.ts +1 -1
- package/Mesher/Geomtry/VoxelMesh.js +4 -4
- package/Mesher/Geomtry/VoxelMeshBVHBuilder.d.ts +16 -0
- package/Mesher/Geomtry/VoxelMeshBVHBuilder.js +51 -0
- package/Mesher/Geomtry/VoxelMeshBVHStructCursor.d.ts +22 -0
- package/Mesher/Geomtry/VoxelMeshBVHStructCursor.js +78 -0
- package/Mesher/Geomtry/{Buffers.js → VoxelMeshBuffers.js} +2 -2
- package/Mesher/Geomtry/index.d.ts +0 -1
- package/Mesher/Geomtry/index.js +0 -1
- package/Mesher/InitMesher.js +1 -1
- package/Mesher/InitTask.js +9 -23
- package/Mesher/Models/Common/BoxGeometryNode.js +7 -7
- package/Mesher/Models/Common/Calc/CalcConstants.d.ts +1 -1
- package/Mesher/Models/Common/Calc/CalcConstants.js +1 -1
- package/Mesher/Models/Common/Calc/FaceDataCalc.d.ts +2 -2
- package/Mesher/Models/Common/Calc/FaceDataCalc.js +37 -30
- package/Mesher/Models/Common/QuadGeometryNode.js +2 -2
- package/Mesher/Models/Nodes/Custom/Liquid/FlowGradient.d.ts +2 -2
- package/Mesher/Models/Nodes/Custom/Liquid/FlowGradient.js +1 -1
- package/Mesher/Models/Nodes/Custom/Liquid/LiquidGeomtryNode.js +18 -24
- package/Mesher/Models/Nodes/GeometryNode.d.ts +2 -2
- package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.d.ts +1 -0
- package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.js +40 -31
- package/Mesher/Models/Nodes/Ruled/QuadVoxelGeometryNode.js +2 -2
- package/Mesher/Models/Nodes/Ruleless/RulelessBoxVoxelGeometryNode.js +2 -2
- package/Mesher/Models/Nodes/Ruleless/RulelessQuadVoxelGeometryNode.js +2 -2
- package/Mesher/{Tools → Models/Protocols}/OutlinedVoxelTool.d.ts +1 -1
- package/Mesher/{Tools → Models/Protocols}/OutlinedVoxelTool.js +1 -1
- package/Mesher/Models/RenderedMaterials.d.ts +6 -0
- package/Mesher/{RenderedMaterials.js → Models/RenderedMaterials.js} +2 -2
- package/Mesher/Models/VoxelConstructor.d.ts +6 -6
- package/Mesher/Models/VoxelConstructor.js +8 -8
- package/Mesher/Models/VoxelGeometryBuilderCacheSpace.d.ts +3 -5
- package/Mesher/Models/VoxelGeometryBuilderCacheSpace.js +8 -32
- package/Mesher/{Tools/VoxelMesherDataTool.d.ts → Models/VoxelModelBuilder.d.ts} +4 -5
- package/Mesher/{Tools/VoxelMesherDataTool.js → Models/VoxelModelBuilder.js} +5 -8
- package/Mesher/Types/Mesher.types.d.ts +1 -0
- package/Models/Defaults/CubeVoxelGeometry.js +4 -0
- package/Models/Defaults/CubeVoxelModels.js +360 -383
- package/Models/Defaults/LiquidVoxelModel.js +5 -5
- package/Models/Defaults/PanelVoxelModels.js +442 -468
- package/Models/Defaults/StairVoxelModel.js +582 -597
- package/Models/Examples.js +490 -498
- package/Models/Rules/Classes/VoxelRulesModel.d.ts +1 -1
- package/Models/Rules/Classes/VoxelRulesModel.js +3 -3
- package/Models/Rules/Functions/BuildFinalInputs.d.ts +1 -1
- package/Models/Rules/Functions/BuildFinalInputs.js +21 -19
- package/Models/Rules/Functions/BuildGeomtryInputs.js +8 -5
- package/Models/Rules/Functions/BuildRules.js +2 -2
- package/Models/Rules/{VoxelModelManager.d.ts → VoxelModelRuleBuilderRegister.d.ts} +1 -1
- package/Models/Rules/VoxelModelRuleBuilderRegister.js +178 -0
- package/Models/VoxelModel.types.d.ts +17 -8
- package/Renderer/Classes/DVESectionMeshes.d.ts +2 -3
- package/Renderer/Classes/SectorMesh.d.ts +3 -4
- package/Renderer/Classes/SectorMesh.js +6 -11
- package/Renderer/InitTasks.js +1 -10
- package/Renderer/MeshManager.d.ts +1 -1
- package/Renderer/MeshManager.js +26 -25
- package/Renderer/MeshRegister.d.ts +5 -5
- package/Renderer/MeshRegister.js +4 -3
- package/Settings/EngineSettings.d.ts +2 -1
- package/Settings/EngineSettings.js +6 -5
- package/Settings/EngineSettings.types.d.ts +24 -39
- package/Settings/EngineSettings.types.js +22 -29
- package/Tasks/Logic/InitTasks.d.ts +1 -0
- package/Tasks/Logic/InitTasks.js +10 -0
- package/Tasks/Logic/VoxelLogicUpdate.d.ts +3 -0
- package/Tasks/Logic/VoxelLogicUpdate.js +71 -0
- package/Tasks/Propagation/Explosion/ExplosionManager.d.ts +2 -2
- package/Tasks/Propagation/Explosion/ExplosionManager.js +1 -2
- package/Tasks/Propagation/Flow/FlowManager.d.ts +4 -4
- package/Tasks/Propagation/Flow/FlowRemove.d.ts +2 -2
- package/Tasks/Propagation/Flow/FlowUpdate.d.ts +2 -2
- package/Tasks/Propagation/Flow/WorldFlow.d.ts +2 -2
- package/Tasks/Propagation/Illumanation/RGBUpdate.d.ts +3 -3
- package/Tasks/Propagation/Illumanation/SunUpdate.d.ts +3 -3
- package/Tasks/Propagation/Illumanation/WorldRGB.d.ts +2 -2
- package/Tasks/Propagation/Illumanation/WorldSun.d.ts +2 -2
- package/Tasks/Propagation/Illumanation/WorldSun.js +8 -15
- package/Tasks/Propagation/InitTasks.js +4 -4
- package/Tasks/Propagation/Power/PowerUpdate.d.ts +3 -0
- package/Tasks/Propagation/Power/PowerUpdate.js +80 -0
- package/Tasks/Tasks.types.d.ts +2 -2
- package/Tasks/TasksIds.d.ts +2 -1
- package/Tasks/TasksIds.js +1 -0
- package/Tasks/Update/Common.d.ts +3 -0
- package/Tasks/Update/Common.js +41 -0
- package/Tasks/Update/EreaseUpdate.d.ts +3 -0
- package/Tasks/Update/EreaseUpdate.js +66 -0
- package/Tasks/Update/InitTasks.d.ts +2 -2
- package/Tasks/Update/InitTasks.js +3 -1
- package/Tasks/Update/PaintUpdate.d.ts +3 -0
- package/Tasks/Update/PaintUpdate.js +89 -0
- package/Tasks/Update/VoxelUpdate.d.ts +2 -5
- package/Tasks/Update/VoxelUpdate.js +7 -143
- package/Tasks/{Update/UpdateTask.d.ts → VoxelUpdateTask.d.ts} +16 -6
- package/Tasks/{Update/UpdateTask.js → VoxelUpdateTask.js} +44 -5
- package/Tasks/WorldGeneration/WorldGenBrush.d.ts +3 -3
- package/Tasks/WorldGeneration/WorldGenBrush.js +3 -3
- package/Tasks/WorldGeneration/WorldGenRegister.d.ts +1 -1
- package/Templates/Cursor/TemplateCursor.d.ts +2 -2
- package/Templates/Cursor/TemplateCursor.js +1 -2
- package/Templates/Functions/CreateTemplate.d.ts +1 -1
- package/Templates/VoxelTemplates.types.d.ts +1 -1
- package/Textures/Classes/CompiledTexture.d.ts +18 -0
- package/Textures/Classes/CompiledTexture.js +50 -0
- package/Textures/Classes/CompiledTextureAnimation.d.ts +12 -0
- package/Textures/Classes/CompiledTextureAnimation.js +27 -0
- package/Textures/Classes/TextureAnimationTexture.d.ts +10 -0
- package/Textures/Classes/TextureAnimationTexture.js +32 -0
- package/Textures/Functions/BuildTextureData.d.ts +10 -0
- package/Textures/Functions/BuildTextureData.js +205 -0
- package/Textures/Texture.types.d.ts +50 -64
- package/Textures/TextureManager.d.ts +8 -19
- package/Textures/TextureManager.js +28 -166
- package/Tools/Brush/AdvancedBrushTool.js +1 -1
- package/Tools/Brush/Brush.d.ts +3 -3
- package/Tools/Brush/Brush.js +40 -8
- package/Tools/Tasks/TasksTool.d.ts +1 -0
- package/Tools/Tasks/TasksTool.js +2 -0
- package/Util/Binary/BinaryArrays.d.ts +6 -0
- package/Util/Binary/BinaryArrays.js +25 -0
- package/Util/Binary/BinaryBuffer.d.ts +35 -0
- package/Util/Binary/BinaryBuffer.js +136 -0
- package/Util/Binary/{BitArray.d.ts → BinaryFunctions.d.ts} +1 -2
- package/Util/Binary/BinaryFunctions.js +11 -0
- package/{Mesher/Tools/VoxelMeshBVHBuilder.d.ts → Util/Binary/BinaryTree.d.ts} +1 -33
- package/Util/Binary/BinaryTree.js +104 -0
- package/Voxels/Cursor/DataCursor.interface.d.ts +5 -0
- package/Voxels/Cursor/VoxelCursor.interface.d.ts +8 -3
- package/Voxels/Cursor/VoxelCursor.interface.js +54 -13
- package/Voxels/Cursor/VoxelLightData.js +1 -1
- package/Voxels/Data/VoxelPalettesRegister.d.ts +0 -5
- package/Voxels/Data/VoxelPalettesRegister.js +0 -9
- package/Voxels/Data/VoxelTag.types.d.ts +17 -2
- package/Voxels/Data/VoxelTag.types.js +6 -1
- package/Voxels/Data/VoxelTagsRegister.js +12 -7
- package/Voxels/Functions/BuildStateData.d.ts +6 -6
- package/Voxels/Functions/BuildStateData.js +37 -37
- package/Voxels/Functions/BuildTagAndPaletteData.js +6 -3
- package/Voxels/Indexes/VoxelIndex.d.ts +2 -2
- package/Voxels/Indexes/VoxelIndex.js +16 -18
- package/Voxels/InitVoxelData.js +24 -21
- package/Voxels/Logic/Classes/Default/Types/VoxelPoweredLogicType.d.ts +5 -0
- package/Voxels/Logic/Classes/Default/Types/VoxelPoweredLogicType.js +6 -0
- package/Voxels/Logic/Classes/VoxelLogic.d.ts +11 -0
- package/Voxels/Logic/Classes/VoxelLogic.js +49 -0
- package/Voxels/Logic/Classes/VoxelLogicType.d.ts +4 -0
- package/Voxels/Logic/Classes/VoxelLogicType.js +2 -0
- package/Voxels/Logic/VoxelLogic.types.d.ts +23 -0
- package/Voxels/Logic/VoxelLogic.types.js +1 -0
- package/Voxels/Logic/VoxelLogicRegister.d.ts +9 -0
- package/Voxels/Logic/VoxelLogicRegister.js +15 -0
- package/Voxels/State/Schema/StateSchema.d.ts +1 -1
- package/Voxels/State/SchemaRegister.js +10 -5
- package/Voxels/State/State.types.d.ts +1 -1
- package/Voxels/State/StateTreeReader.d.ts +1 -1
- package/Voxels/State/StateTreeReader.js +2 -3
- package/Voxels/Types/Voxel.types.d.ts +21 -0
- package/Voxels/Types/Voxel.types.js +6 -2
- package/Voxels/Types/VoxelModelCompiledData.types.d.ts +6 -4
- package/World/Archive/Archive.types.d.ts +65 -42
- package/World/Archive/Classes/ArchiveClasses.d.ts +66 -0
- package/World/Archive/Classes/ArchiveClasses.js +78 -0
- package/World/Archive/Classes/ImportedSection.d.ts +40 -0
- package/World/Archive/Classes/ImportedSection.js +307 -0
- package/World/Archive/Classes/ImportedSector.d.ts +23 -0
- package/World/Archive/Classes/ImportedSector.js +97 -0
- package/World/Archive/Functions/ArchiveArea.d.ts +1 -1
- package/World/Archive/Functions/ArchiveArea.js +49 -54
- package/World/Archive/Functions/ArchiveSector.js +373 -282
- package/World/Archive/Functions/CreateArchivedSection.d.ts +3 -0
- package/World/Archive/Functions/CreateArchivedSection.js +207 -0
- package/World/Archive/Functions/ImportSector.d.ts +2 -4
- package/World/Archive/Functions/ImportSector.js +50 -220
- package/World/Archive/Functions/RemoveDuplicates.d.ts +3 -0
- package/World/Archive/Functions/RemoveDuplicates.js +92 -0
- package/World/Archive/Functions/Shared.d.ts +6 -0
- package/World/Archive/Functions/Shared.js +50 -0
- package/World/Archive/InitTasks.js +37 -23
- package/World/Cursor/SectionCursor.d.ts +3 -3
- package/World/Cursor/SectionCursor.js +2 -3
- package/World/Cursor/SectorCursor.d.ts +3 -3
- package/World/Cursor/SectorCursor.js +1 -2
- package/World/Cursor/WorldCursor.d.ts +6 -5
- package/World/Cursor/WorldCursor.js +17 -15
- package/World/Cursor/WorldVoxelCursor.d.ts +0 -4
- package/World/Cursor/WorldVoxelCursor.js +24 -14
- package/World/Dimension/Dimension.d.ts +4 -1
- package/World/Dimension/Dimension.js +8 -1
- package/World/InitTasks.d.ts +1 -1
- package/World/Lock/WorldLock.d.ts +1 -1
- package/World/Section/Section.d.ts +27 -18
- package/World/Section/Section.js +125 -21
- package/World/Section/SectionState.d.ts +12 -0
- package/World/Section/SectionState.js +13 -0
- package/World/Sector/Sector.d.ts +20 -6
- package/World/Sector/Sector.js +100 -17
- package/World/Sector/SectorHeightMap.js +2 -2
- package/World/Sector/SectorState.d.ts +16 -7
- package/World/Sector/SectorState.js +29 -15
- package/World/Types/WorldData.types.d.ts +2 -7
- package/World/Types/WorldStorage.interface.js +1 -0
- package/World/WorldRegister.d.ts +13 -9
- package/World/WorldRegister.js +24 -9
- package/World/WorldSpaces.d.ts +4 -0
- package/World/WorldSpaces.js +25 -12
- package/{Tasks/IWG → WorldSimulation}/Internal/Classes/DimensionSegment.d.ts +2 -2
- package/{Tasks/IWG → WorldSimulation}/Internal/Classes/Generator.d.ts +10 -3
- package/{Tasks/IWG → WorldSimulation}/Internal/Classes/Generator.js +19 -3
- package/WorldSimulation/Internal/Classes/Queues/BuildQueue.d.ts +5 -0
- package/WorldSimulation/Internal/Classes/Queues/BuildQueue.js +6 -0
- package/WorldSimulation/Internal/Classes/Queues/LogiccQueue.d.ts +5 -0
- package/WorldSimulation/Internal/Classes/Queues/LogiccQueue.js +6 -0
- package/{Tasks/IWG → WorldSimulation}/Internal/Classes/SectorVisistedMap.js +1 -1
- package/WorldSimulation/Internal/Classes/TickQueue.d.ts +12 -0
- package/WorldSimulation/Internal/Classes/TickQueue.js +58 -0
- package/WorldSimulation/Internal/Classes/WorldSimulationTaskBase.d.ts +15 -0
- package/{Tasks/IWG/Internal/Classes/IWGTaskBase.js → WorldSimulation/Internal/Classes/WorldSimulationTaskBase.js} +8 -8
- package/{Tasks/IWG → WorldSimulation}/Internal/Functions/cullSectors.js +9 -9
- package/{Tasks/IWG → WorldSimulation}/Internal/Functions/getSectorState.d.ts +1 -1
- package/{Tasks/IWG → WorldSimulation}/Internal/Functions/getSectorState.js +4 -4
- package/WorldSimulation/Internal/Functions/runTickUpdate.d.ts +2 -0
- package/{Tasks/IWG/Internal/Functions/runBuildUpdate.js → WorldSimulation/Internal/Functions/runTickUpdate.js} +38 -9
- package/{Tasks/IWG → WorldSimulation}/Internal/Functions/runWorldUpdate.js +13 -13
- package/{Tasks/IWG → WorldSimulation}/Internal/TaskRegister.d.ts +2 -2
- package/{Tasks/IWG → WorldSimulation}/Internal/TaskRegister.js +1 -1
- package/WorldSimulation/Internal/WorldSimulationDimensions.d.ts +6 -0
- package/{Tasks/IWG/Internal/IWGDimensions.js → WorldSimulation/Internal/WorldSimulationDimensions.js} +1 -1
- package/WorldSimulation/Internal/WorldSimulationTasks.d.ts +30 -0
- package/{Tasks/IWG/Internal/IWGTasks.js → WorldSimulation/Internal/WorldSimulationTasks.js} +14 -24
- package/WorldSimulation/Internal/WorldSimulationTools.d.ts +8 -0
- package/{Tasks/IWG/Internal/IWGTools.js → WorldSimulation/Internal/WorldSimulationTools.js} +1 -1
- package/{Tasks/IWG → WorldSimulation}/Procedures/InitalLoad.d.ts +1 -1
- package/{Tasks/IWG → WorldSimulation}/Procedures/InitalLoad.js +11 -11
- package/{Tasks/IWG → WorldSimulation}/Procedures/SaveAllSectors.js +7 -5
- package/{Tasks/IWG/IWG.d.ts → WorldSimulation/WorldSimulation.d.ts} +6 -5
- package/{Tasks/IWG/IWG.js → WorldSimulation/WorldSimulation.js} +29 -23
- package/{Tasks/IWG → WorldSimulation}/index.d.ts +1 -1
- package/{Tasks/IWG → WorldSimulation}/index.js +1 -1
- package/package.json +1 -1
- package/Mesher/Functions/CompactMesh.d.ts +0 -2
- package/Mesher/Functions/CompactMesh.js +0 -42
- package/Mesher/Geomtry/GeometryNormals.d.ts +0 -10
- package/Mesher/Geomtry/GeometryNormals.js +0 -52
- package/Mesher/Geomtry/MeshData.types.d.ts +0 -13
- package/Mesher/Geomtry/MeshData.types.js +0 -6
- package/Mesher/Geomtry/Tools/MesherDataTools.d.ts +0 -7
- package/Mesher/Geomtry/Tools/MesherDataTools.js +0 -12
- package/Mesher/Geomtry/Tools/index.d.ts +0 -1
- package/Mesher/Geomtry/Tools/index.js +0 -1
- package/Mesher/RenderedMaterials.d.ts +0 -6
- package/Mesher/Tools/VoxelMeshBVHBuilder.js +0 -216
- package/Models/Rules/VoxelModelManager.js +0 -82
- package/Tasks/IWG/Internal/Classes/IWGTaskBase.d.ts +0 -15
- package/Tasks/IWG/Internal/Functions/runBuildUpdate.d.ts +0 -2
- package/Tasks/IWG/Internal/IWGDimensions.d.ts +0 -6
- package/Tasks/IWG/Internal/IWGTasks.d.ts +0 -34
- package/Tasks/IWG/Internal/IWGTools.d.ts +0 -8
- package/Textures/TextureAnimations.d.ts +0 -4
- package/Textures/TextureAnimations.js +0 -35
- package/Textures/TextureArray.d.ts +0 -47
- package/Textures/TextureArray.js +0 -202
- package/Textures/TextureBuilder.d.ts +0 -13
- package/Textures/TextureBuilder.js +0 -120
- package/Textures/TextureRegister.d.ts +0 -9
- package/Textures/TextureRegister.js +0 -28
- package/Tools/DataCursor.interface.d.ts +0 -5
- package/Tools/DataCursor.interface.js +0 -2
- package/Util/Binary/BitArray.js +0 -16
- package/World/Structs/WorldDataStructProperties.d.ts +0 -8
- package/World/Structs/WorldDataStructProperties.js +0 -9
- /package/Mesher/Geomtry/{Buffers.d.ts → VoxelMeshBuffers.d.ts} +0 -0
- /package/Mesher/{Tools → Geomtry}/VoxelMeshVertexStructCursor.d.ts +0 -0
- /package/Mesher/{Tools → Geomtry}/VoxelMeshVertexStructCursor.js +0 -0
- /package/Mesher/{VoxelShaderData.d.ts → Geomtry/VoxelShaderData.d.ts} +0 -0
- /package/Mesher/{VoxelShaderData.js → Geomtry/VoxelShaderData.js} +0 -0
- /package/{World/Storage/WorldStorage.interface.js → Voxels/Cursor/DataCursor.interface.js} +0 -0
- /package/World/{Storage → Types}/WorldStorage.interface.d.ts +0 -0
- /package/{Tasks/IWG → WorldSimulation}/Internal/Classes/DimensionSegment.js +0 -0
- /package/{Tasks/IWG → WorldSimulation}/Internal/Classes/SectorState.d.ts +0 -0
- /package/{Tasks/IWG → WorldSimulation}/Internal/Classes/SectorState.js +0 -0
- /package/{Tasks/IWG → WorldSimulation}/Internal/Classes/SectorVisistedMap.d.ts +0 -0
- /package/{Tasks/IWG → WorldSimulation}/Internal/Functions/cullSectors.d.ts +0 -0
- /package/{Tasks/IWG → WorldSimulation}/Internal/Functions/runWorldUpdate.d.ts +0 -0
- /package/{Tasks/IWG → WorldSimulation}/Procedures/SaveAllSectors.d.ts +0 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare enum SectionStateDefaultFlags {
|
|
2
|
+
displayDirty = 0,
|
|
3
|
+
logicDirty = 1,
|
|
4
|
+
inProgress = 2,
|
|
5
|
+
logicUpdateInProgress = 3
|
|
6
|
+
}
|
|
7
|
+
export declare class SectionState {
|
|
8
|
+
/**The default bit flags for sections */
|
|
9
|
+
static Flags: typeof SectionStateDefaultFlags;
|
|
10
|
+
/**A record of bit flags tht are preserved when the section is stored */
|
|
11
|
+
static StoredFlags: Record<string, number>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export var SectionStateDefaultFlags;
|
|
2
|
+
(function (SectionStateDefaultFlags) {
|
|
3
|
+
SectionStateDefaultFlags[SectionStateDefaultFlags["displayDirty"] = 0] = "displayDirty";
|
|
4
|
+
SectionStateDefaultFlags[SectionStateDefaultFlags["logicDirty"] = 1] = "logicDirty";
|
|
5
|
+
SectionStateDefaultFlags[SectionStateDefaultFlags["inProgress"] = 2] = "inProgress";
|
|
6
|
+
SectionStateDefaultFlags[SectionStateDefaultFlags["logicUpdateInProgress"] = 3] = "logicUpdateInProgress";
|
|
7
|
+
})(SectionStateDefaultFlags || (SectionStateDefaultFlags = {}));
|
|
8
|
+
export class SectionState {
|
|
9
|
+
/**The default bit flags for sections */
|
|
10
|
+
static Flags = SectionStateDefaultFlags;
|
|
11
|
+
/**A record of bit flags tht are preserved when the section is stored */
|
|
12
|
+
static StoredFlags = {};
|
|
13
|
+
}
|
package/World/Sector/Sector.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Section, SectionData } from "../Section/Section.js";
|
|
2
2
|
import { Vec3Array } from "@amodx/math";
|
|
3
|
-
import {
|
|
3
|
+
import { SectorStateDefaultBitFlags } from "./SectorState.js";
|
|
4
4
|
export interface SectorData {
|
|
5
|
-
position: Vec3Array;
|
|
6
5
|
buffer: ArrayBufferLike;
|
|
7
6
|
/**Array of timestamps for the sector */
|
|
8
7
|
timeStampArray: Uint32Array;
|
|
@@ -13,18 +12,33 @@ export interface SectorData {
|
|
|
13
12
|
export interface Sector extends SectorData {
|
|
14
13
|
}
|
|
15
14
|
export declare class Sector {
|
|
16
|
-
|
|
17
|
-
static
|
|
15
|
+
position: Vec3Array;
|
|
16
|
+
static FlagIds: typeof SectorStateDefaultBitFlags;
|
|
17
|
+
static TimeStampIds: typeof import("./SectorState.js").SectorStateDefaultTimeStamps;
|
|
18
18
|
static GetHeaderSize(): number;
|
|
19
19
|
static GetBufferSize(): number;
|
|
20
20
|
static CreateNew(): SectorData;
|
|
21
21
|
sections: Section[];
|
|
22
22
|
bufferView: Uint8Array;
|
|
23
|
-
constructor(data: SectorData);
|
|
24
|
-
getSection(y: number): Section;
|
|
23
|
+
constructor(data: SectorData, position: Vec3Array);
|
|
24
|
+
getSection(x: number, y: number, z: number): Section;
|
|
25
25
|
setBitFlag(index: number, value: boolean): void;
|
|
26
26
|
getBitFlag(index: number): boolean;
|
|
27
|
+
isDisplayDirty(): boolean;
|
|
28
|
+
setDisplayDirty(stored: boolean): void;
|
|
29
|
+
isLogicDirty(): boolean;
|
|
30
|
+
setLogicDirty(stored: boolean): void;
|
|
31
|
+
setStored(stored: boolean): void;
|
|
32
|
+
isStored(): boolean;
|
|
27
33
|
setTimeStamp(index: number, value: number): void;
|
|
28
34
|
getTimeStamp(index: number): number;
|
|
35
|
+
getRenerableSections(): Generator<Section>;
|
|
36
|
+
getLogicDirtySections(): Generator<Section>;
|
|
37
|
+
anySectionDisplayDirty(): boolean;
|
|
38
|
+
anySectionLogicDirty(): boolean;
|
|
39
|
+
storeFlags(): Record<string, boolean>;
|
|
40
|
+
loadFlags(flags: Record<string, boolean>): void;
|
|
41
|
+
storeTimestamps(): Record<string, number>;
|
|
42
|
+
loadTimestamps(stored: Record<string, number>): void;
|
|
29
43
|
toJSON(): SectorData;
|
|
30
44
|
}
|
package/World/Sector/Sector.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { Section } from "../Section/Section.js";
|
|
2
2
|
import { WorldSpaces } from "../WorldSpaces";
|
|
3
|
-
import { getBitArrayIndex, setBitArrayIndex, } from "../../Util/Binary/
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
return n % 2 === 0 ? n : n + 1;
|
|
7
|
-
}
|
|
3
|
+
import { getBitArrayIndex, setBitArrayIndex, } from "../../Util/Binary/BinaryArrays.js";
|
|
4
|
+
import { SectorState, SectorStateDefaultBitFlags } from "./SectorState.js";
|
|
5
|
+
import { forceMultipleOf2 } from "../../Util/Binary/BinaryFunctions.js";
|
|
8
6
|
export class Sector {
|
|
9
|
-
|
|
10
|
-
static
|
|
7
|
+
position;
|
|
8
|
+
static FlagIds = SectorState.Flags;
|
|
9
|
+
static TimeStampIds = SectorState.TimeStamps;
|
|
11
10
|
static GetHeaderSize() {
|
|
12
11
|
return forceMultipleOf2(
|
|
13
12
|
//12 bytes fot flags
|
|
@@ -22,14 +21,13 @@ export class Sector {
|
|
|
22
21
|
static CreateNew() {
|
|
23
22
|
const buffer = new SharedArrayBuffer(this.GetBufferSize());
|
|
24
23
|
const flagArray = new Uint8Array(buffer, 0, 12);
|
|
25
|
-
const timeStampArray = new Uint32Array(buffer, 12, 12
|
|
24
|
+
const timeStampArray = new Uint32Array(buffer, 12, 12);
|
|
26
25
|
const sections = [];
|
|
27
|
-
const totalSections = WorldSpaces.sector.
|
|
26
|
+
const totalSections = WorldSpaces.sector.sectionVolumne;
|
|
28
27
|
for (let i = 0; i < totalSections; i++) {
|
|
29
28
|
sections[i] = Section.CreateNew(i, buffer);
|
|
30
29
|
}
|
|
31
30
|
return {
|
|
32
|
-
position: [0, 0, 0],
|
|
33
31
|
buffer,
|
|
34
32
|
flagArray,
|
|
35
33
|
timeStampArray,
|
|
@@ -38,8 +36,8 @@ export class Sector {
|
|
|
38
36
|
}
|
|
39
37
|
sections = [];
|
|
40
38
|
bufferView;
|
|
41
|
-
constructor(data) {
|
|
42
|
-
this.position =
|
|
39
|
+
constructor(data, position) {
|
|
40
|
+
this.position = position;
|
|
43
41
|
this.flagArray = data.flagArray;
|
|
44
42
|
this.timeStampArray = data.timeStampArray;
|
|
45
43
|
this.buffer = data.buffer;
|
|
@@ -48,10 +46,8 @@ export class Sector {
|
|
|
48
46
|
this.sections[i] = new Section(this, i, data.sections[i]);
|
|
49
47
|
}
|
|
50
48
|
}
|
|
51
|
-
getSection(y) {
|
|
52
|
-
|
|
53
|
-
const index = ry / WorldSpaces.section.bounds.y;
|
|
54
|
-
return this.sections[index];
|
|
49
|
+
getSection(x, y, z) {
|
|
50
|
+
return this.sections[WorldSpaces.section.getIndex(x, y, z)];
|
|
55
51
|
}
|
|
56
52
|
setBitFlag(index, value) {
|
|
57
53
|
setBitArrayIndex(this.flagArray, index, value ? 1 : 0);
|
|
@@ -59,19 +55,106 @@ export class Sector {
|
|
|
59
55
|
getBitFlag(index) {
|
|
60
56
|
return getBitArrayIndex(this.flagArray, index) == 1;
|
|
61
57
|
}
|
|
58
|
+
isDisplayDirty() {
|
|
59
|
+
return this.getBitFlag(SectorStateDefaultBitFlags.displayDirty);
|
|
60
|
+
}
|
|
61
|
+
setDisplayDirty(stored) {
|
|
62
|
+
this.setBitFlag(SectorStateDefaultBitFlags.displayDirty, stored);
|
|
63
|
+
}
|
|
64
|
+
isLogicDirty() {
|
|
65
|
+
return this.getBitFlag(SectorStateDefaultBitFlags.logicDirty);
|
|
66
|
+
}
|
|
67
|
+
setLogicDirty(stored) {
|
|
68
|
+
this.setBitFlag(SectorStateDefaultBitFlags.logicDirty, stored);
|
|
69
|
+
}
|
|
70
|
+
setStored(stored) {
|
|
71
|
+
this.setBitFlag(SectorStateDefaultBitFlags.stored, stored);
|
|
72
|
+
}
|
|
73
|
+
isStored() {
|
|
74
|
+
return this.getBitFlag(SectorStateDefaultBitFlags.stored);
|
|
75
|
+
}
|
|
62
76
|
setTimeStamp(index, value) {
|
|
63
77
|
this.timeStampArray[index] = value;
|
|
64
78
|
}
|
|
65
79
|
getTimeStamp(index) {
|
|
66
80
|
return this.timeStampArray[index];
|
|
67
81
|
}
|
|
82
|
+
*getRenerableSections() {
|
|
83
|
+
for (const section of this.sections) {
|
|
84
|
+
const [min, max] = section.getMinMax();
|
|
85
|
+
if (min == Infinity || max == -Infinity)
|
|
86
|
+
continue;
|
|
87
|
+
yield section;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
*getLogicDirtySections() {
|
|
91
|
+
for (const section of this.sections) {
|
|
92
|
+
const [min, max] = section.getLogicMinMax();
|
|
93
|
+
if (min == Infinity || max == -Infinity)
|
|
94
|
+
continue;
|
|
95
|
+
yield section;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
anySectionDisplayDirty() {
|
|
99
|
+
if (!this.isDisplayDirty())
|
|
100
|
+
return false;
|
|
101
|
+
for (let i = 0; i < this.sections.length; i++) {
|
|
102
|
+
if (this.sections[i].isDisplayDirty() && !this.sections[i].isInProgress())
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
this.setDisplayDirty(false);
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
anySectionLogicDirty() {
|
|
109
|
+
if (!this.isLogicDirty())
|
|
110
|
+
return false;
|
|
111
|
+
for (let i = 0; i < this.sections.length; i++) {
|
|
112
|
+
if (this.sections[i].isLogicDirty() && !this.sections[i].isLogicUpdateInProgress())
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
this.setLogicDirty(false);
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
storeFlags() {
|
|
119
|
+
const stored = {};
|
|
120
|
+
for (const key in SectorState.StoredFlags) {
|
|
121
|
+
stored[key] = this.getBitFlag(SectorState.StoredFlags[key]);
|
|
122
|
+
}
|
|
123
|
+
return stored;
|
|
124
|
+
}
|
|
125
|
+
loadFlags(flags) {
|
|
126
|
+
for (const flag in flags) {
|
|
127
|
+
const storedIndex = SectorState.StoredFlags[flag];
|
|
128
|
+
if (storedIndex === undefined) {
|
|
129
|
+
console.warn(`${flag} does not exist on stored flags for sector`);
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
this.setBitFlag(storedIndex, flags[flag]);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
storeTimestamps() {
|
|
136
|
+
const stored = {};
|
|
137
|
+
for (const key in SectorState.StoredTimeStamps) {
|
|
138
|
+
stored[key] = this.getTimeStamp(SectorState.StoredTimeStamps[key]);
|
|
139
|
+
}
|
|
140
|
+
return stored;
|
|
141
|
+
}
|
|
142
|
+
loadTimestamps(stored) {
|
|
143
|
+
for (const timeStamp in stored) {
|
|
144
|
+
const storedIndex = SectorState.StoredTimeStamps[timeStamp];
|
|
145
|
+
if (storedIndex === undefined) {
|
|
146
|
+
console.warn(`${timeStamp} does not exist on stored timestamps for sector`);
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
this.setTimeStamp(storedIndex, stored[timeStamp]);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
68
152
|
toJSON() {
|
|
69
153
|
const sections = [];
|
|
70
154
|
for (const section of this.sections) {
|
|
71
155
|
sections.push(section.toJSON());
|
|
72
156
|
}
|
|
73
157
|
return {
|
|
74
|
-
position: this.position,
|
|
75
158
|
buffer: this.buffer,
|
|
76
159
|
flagArray: this.flagArray,
|
|
77
160
|
timeStampArray: this.timeStampArray,
|
|
@@ -31,11 +31,11 @@ export class SectorHeightMap {
|
|
|
31
31
|
const section = sector.sections[i];
|
|
32
32
|
if (!section)
|
|
33
33
|
continue;
|
|
34
|
-
const sectionPOS =
|
|
34
|
+
const sectionPOS = section.getPosition();
|
|
35
35
|
let [sectionMin, sectionMax] = section.getMinMax();
|
|
36
36
|
if (Math.abs(sectionMax) == Infinity)
|
|
37
37
|
continue;
|
|
38
|
-
sectionMax = sectionPOS + sectionMax;
|
|
38
|
+
sectionMax = sectionPOS[1] + sectionMax;
|
|
39
39
|
if (maxHeight < sectionMax) {
|
|
40
40
|
maxHeight = sectionMax;
|
|
41
41
|
}
|
|
@@ -1,13 +1,22 @@
|
|
|
1
|
-
export declare enum
|
|
1
|
+
export declare enum SectorStateDefaultBitFlags {
|
|
2
2
|
isWorldGenDone = 0,
|
|
3
3
|
isWorldDecorDone = 1,
|
|
4
4
|
isWorldPropagationDone = 2,
|
|
5
5
|
isWorldSunDone = 3,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
displayDirty = 4,
|
|
7
|
+
logicDirty = 5,
|
|
8
|
+
stored = 6
|
|
9
9
|
}
|
|
10
|
-
export declare enum
|
|
11
|
-
lastSaveTimestamp = 0
|
|
12
|
-
|
|
10
|
+
export declare enum SectorStateDefaultTimeStamps {
|
|
11
|
+
lastSaveTimestamp = 0
|
|
12
|
+
}
|
|
13
|
+
export declare class SectorState {
|
|
14
|
+
/**The default bit flags for secotrs */
|
|
15
|
+
static Flags: typeof SectorStateDefaultBitFlags;
|
|
16
|
+
/**An array of bit flags tht are preserved when the sector is stored */
|
|
17
|
+
static StoredFlags: Record<string, number>;
|
|
18
|
+
/**The default timestamps for secotrs */
|
|
19
|
+
static TimeStamps: typeof SectorStateDefaultTimeStamps;
|
|
20
|
+
/**An array of bit timestamps tht are preserved when the sector is stored */
|
|
21
|
+
static StoredTimeStamps: Record<string, number>;
|
|
13
22
|
}
|
|
@@ -1,15 +1,29 @@
|
|
|
1
|
-
export var
|
|
2
|
-
(function (
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
})(
|
|
11
|
-
export var
|
|
12
|
-
(function (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
export var SectorStateDefaultBitFlags;
|
|
2
|
+
(function (SectorStateDefaultBitFlags) {
|
|
3
|
+
SectorStateDefaultBitFlags[SectorStateDefaultBitFlags["isWorldGenDone"] = 0] = "isWorldGenDone";
|
|
4
|
+
SectorStateDefaultBitFlags[SectorStateDefaultBitFlags["isWorldDecorDone"] = 1] = "isWorldDecorDone";
|
|
5
|
+
SectorStateDefaultBitFlags[SectorStateDefaultBitFlags["isWorldPropagationDone"] = 2] = "isWorldPropagationDone";
|
|
6
|
+
SectorStateDefaultBitFlags[SectorStateDefaultBitFlags["isWorldSunDone"] = 3] = "isWorldSunDone";
|
|
7
|
+
SectorStateDefaultBitFlags[SectorStateDefaultBitFlags["displayDirty"] = 4] = "displayDirty";
|
|
8
|
+
SectorStateDefaultBitFlags[SectorStateDefaultBitFlags["logicDirty"] = 5] = "logicDirty";
|
|
9
|
+
SectorStateDefaultBitFlags[SectorStateDefaultBitFlags["stored"] = 6] = "stored";
|
|
10
|
+
})(SectorStateDefaultBitFlags || (SectorStateDefaultBitFlags = {}));
|
|
11
|
+
export var SectorStateDefaultTimeStamps;
|
|
12
|
+
(function (SectorStateDefaultTimeStamps) {
|
|
13
|
+
SectorStateDefaultTimeStamps[SectorStateDefaultTimeStamps["lastSaveTimestamp"] = 0] = "lastSaveTimestamp";
|
|
14
|
+
})(SectorStateDefaultTimeStamps || (SectorStateDefaultTimeStamps = {}));
|
|
15
|
+
export class SectorState {
|
|
16
|
+
/**The default bit flags for secotrs */
|
|
17
|
+
static Flags = SectorStateDefaultBitFlags;
|
|
18
|
+
/**An array of bit flags tht are preserved when the sector is stored */
|
|
19
|
+
static StoredFlags = {
|
|
20
|
+
dve_is_world_gen_done: SectorStateDefaultBitFlags.isWorldGenDone,
|
|
21
|
+
dve_is_world_decoration_done: SectorStateDefaultBitFlags.isWorldDecorDone,
|
|
22
|
+
dve_is_world_progation_done: SectorStateDefaultBitFlags.isWorldPropagationDone,
|
|
23
|
+
dve_is_world_sun_done: SectorStateDefaultBitFlags.isWorldSunDone,
|
|
24
|
+
};
|
|
25
|
+
/**The default timestamps for secotrs */
|
|
26
|
+
static TimeStamps = SectorStateDefaultTimeStamps;
|
|
27
|
+
/**An array of bit timestamps tht are preserved when the sector is stored */
|
|
28
|
+
static StoredTimeStamps = {};
|
|
29
|
+
}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
export type
|
|
2
|
-
liquidFlowSpeed: number;
|
|
3
|
-
magmaFlowSpeed: number;
|
|
4
|
-
sunLight: boolean;
|
|
5
|
-
};
|
|
6
|
-
export type DimensionData = {
|
|
1
|
+
export type DimensionSyncData = {
|
|
7
2
|
id: string;
|
|
8
|
-
|
|
3
|
+
index: number;
|
|
9
4
|
};
|
|
10
5
|
export type RichDataSchema = Record<string, Record<string, any>>;
|
|
11
6
|
export type RichSector = {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/World/WorldRegister.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Dimension } from "./Dimension/Dimension";
|
|
2
2
|
import { Sector, SectorData } from "./Sector/Sector.js";
|
|
3
3
|
import type { LocationData } from "../Math/index.js";
|
|
4
|
-
import {
|
|
4
|
+
import { DimensionSyncData } from "./Types/WorldData.types.js";
|
|
5
5
|
declare class WorldDataHooks {
|
|
6
6
|
static dimension: {
|
|
7
|
-
onNew: (dimension:
|
|
7
|
+
onNew: (dimension: DimensionSyncData) => void;
|
|
8
8
|
onRemove: (location: LocationData) => void;
|
|
9
9
|
};
|
|
10
10
|
static sectors: {
|
|
@@ -13,18 +13,22 @@ declare class WorldDataHooks {
|
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
15
|
declare class WorldRegisterDimensions {
|
|
16
|
-
static add(
|
|
17
|
-
static get(
|
|
16
|
+
static add(index: number, id?: string): Dimension;
|
|
17
|
+
static get(index: number): Dimension | undefined;
|
|
18
18
|
}
|
|
19
19
|
declare class WorldRegisterSectors {
|
|
20
20
|
static setSecotrPool(enabled: boolean): void;
|
|
21
|
-
static add(dimensionId:
|
|
22
|
-
static
|
|
23
|
-
static
|
|
24
|
-
static
|
|
21
|
+
static add(dimensionId: number, x: number, y: number, z: number, sector: SectorData): Sector;
|
|
22
|
+
static addAt(location: LocationData, sector: SectorData): Sector;
|
|
23
|
+
static new(dimensionId: number, x: number, y: number, z: number): boolean;
|
|
24
|
+
static newAt(location: LocationData): boolean;
|
|
25
|
+
static get(dimensionId: number, x: number, y: number, z: number): false | Sector;
|
|
26
|
+
static getAt(location: LocationData): false | Sector;
|
|
27
|
+
static remove(dimensionId: number, x: number, y: number, z: number): boolean;
|
|
28
|
+
static removeAt(location: LocationData): boolean;
|
|
25
29
|
}
|
|
26
30
|
export declare class WorldRegister {
|
|
27
|
-
static _dimensions: Map<
|
|
31
|
+
static _dimensions: Map<number, Dimension>;
|
|
28
32
|
static _hooks: typeof WorldDataHooks;
|
|
29
33
|
static dimensions: typeof WorldRegisterDimensions;
|
|
30
34
|
static sectors: typeof WorldRegisterSectors;
|
package/World/WorldRegister.js
CHANGED
|
@@ -13,13 +13,14 @@ class WorldDataHooks {
|
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
15
|
class WorldRegisterDimensions {
|
|
16
|
-
static add(id) {
|
|
17
|
-
const dimesnion = Dimension.CreateNew(id);
|
|
18
|
-
WorldRegister._dimensions.set(
|
|
16
|
+
static add(index, id = "") {
|
|
17
|
+
const dimesnion = Dimension.CreateNew(index, id);
|
|
18
|
+
WorldRegister._dimensions.set(index, dimesnion);
|
|
19
|
+
WorldDataHooks.dimension.onNew(dimesnion.getData());
|
|
19
20
|
return dimesnion;
|
|
20
21
|
}
|
|
21
|
-
static get(
|
|
22
|
-
return WorldRegister._dimensions.get(
|
|
22
|
+
static get(index) {
|
|
23
|
+
return WorldRegister._dimensions.get(index);
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
const tempPosition = Vector3Like.Create();
|
|
@@ -35,6 +36,7 @@ class SectorPool {
|
|
|
35
36
|
}
|
|
36
37
|
static returnSector(secotr) {
|
|
37
38
|
secotr.bufferView.fill(0);
|
|
39
|
+
this._secotrs.push(secotr.toJSON());
|
|
38
40
|
}
|
|
39
41
|
}
|
|
40
42
|
class WorldRegisterSectors {
|
|
@@ -46,21 +48,26 @@ class WorldRegisterSectors {
|
|
|
46
48
|
let dimension = WorldRegister.dimensions.get(dimensionId);
|
|
47
49
|
if (!dimension)
|
|
48
50
|
dimension = WorldRegister.dimensions.add(dimensionId);
|
|
49
|
-
WorldSpaces.sector.getPositionVec3Array(x, y, z
|
|
50
|
-
const newSector = new Sector(sector);
|
|
51
|
+
const newSector = new Sector(sector, WorldSpaces.sector.getPositionVec3Array(x, y, z));
|
|
51
52
|
dimension.sectors.set(WorldSpaces.hash.hashVec3Array(newSector.position), newSector);
|
|
52
53
|
return newSector;
|
|
53
54
|
}
|
|
55
|
+
static addAt(location, sector) {
|
|
56
|
+
return this.add(...location, sector);
|
|
57
|
+
}
|
|
54
58
|
static new(dimensionId, x, y, z) {
|
|
55
59
|
if (this.get(dimensionId, x, y, z))
|
|
56
60
|
return false;
|
|
57
61
|
let dimension = WorldRegister.dimensions.get(dimensionId);
|
|
58
62
|
if (!dimension)
|
|
59
63
|
dimension = WorldRegister.dimensions.add(dimensionId);
|
|
60
|
-
const sector = this.add(dimensionId, x, y, z,
|
|
64
|
+
const sector = this.add(dimensionId, x, y, z, SectorPool.getSector());
|
|
61
65
|
WorldDataHooks.sectors.onNew([dimensionId, x, y, z], sector);
|
|
62
66
|
return true;
|
|
63
67
|
}
|
|
68
|
+
static newAt(location) {
|
|
69
|
+
return this.new(...location);
|
|
70
|
+
}
|
|
64
71
|
static get(dimensionId, x, y, z) {
|
|
65
72
|
let dimension = WorldRegister.dimensions.get(dimensionId);
|
|
66
73
|
if (!dimension)
|
|
@@ -68,6 +75,9 @@ class WorldRegisterSectors {
|
|
|
68
75
|
const sector = dimension.sectors.get(WorldSpaces.hash.hashVec3(WorldSpaces.sector.getPosition(x, y, z, tempPosition)));
|
|
69
76
|
return sector || false;
|
|
70
77
|
}
|
|
78
|
+
static getAt(location) {
|
|
79
|
+
return this.get(...location);
|
|
80
|
+
}
|
|
71
81
|
static remove(dimensionId, x, y, z) {
|
|
72
82
|
let dimension = WorldRegister.dimensions.get(dimensionId);
|
|
73
83
|
if (!dimension)
|
|
@@ -83,9 +93,14 @@ class WorldRegisterSectors {
|
|
|
83
93
|
dimension.sectors.delete(sectorKey);
|
|
84
94
|
return true;
|
|
85
95
|
}
|
|
96
|
+
static removeAt(location) {
|
|
97
|
+
return this.remove(...location);
|
|
98
|
+
}
|
|
86
99
|
}
|
|
87
100
|
export class WorldRegister {
|
|
88
|
-
static _dimensions = new Map(
|
|
101
|
+
static _dimensions = new Map([
|
|
102
|
+
[0, new Dimension(Dimension.CreateNew(0, "main"))],
|
|
103
|
+
]);
|
|
89
104
|
static _hooks = WorldDataHooks;
|
|
90
105
|
static dimensions = WorldRegisterDimensions;
|
|
91
106
|
static sectors = WorldRegisterSectors;
|
package/World/WorldSpaces.d.ts
CHANGED
|
@@ -23,6 +23,8 @@ declare class SectorSpace {
|
|
|
23
23
|
static power2Axes: Vector3Like;
|
|
24
24
|
static bounds: Vector3Like;
|
|
25
25
|
static volumne: number;
|
|
26
|
+
static sectionBounds: Vector3Like;
|
|
27
|
+
static sectionVolumne: number;
|
|
26
28
|
static getPosition(x: number, y: number, z: number, refPosition?: Vector3Like): Vector3Like;
|
|
27
29
|
static getPositionVec3Array(x: number, y: number, z: number, refPosition?: Vec3Array): Vec3Array;
|
|
28
30
|
}
|
|
@@ -33,6 +35,8 @@ declare class SectionSpace {
|
|
|
33
35
|
static getPosition(x: number, y: number, z: number, refPosition?: Vector3Like): Vector3Like;
|
|
34
36
|
static getPositionVec3Array(x: number, y: number, z: number, refPosition?: Vec3Array): Vec3Array;
|
|
35
37
|
static getIndex(x: number, y: number, z: number): number;
|
|
38
|
+
static getPositionFromIndex(index: number, refPosition?: Vector3Like): Vector3Like;
|
|
39
|
+
static getPositionFromIndexVec3Array(index: number, refPosition?: Vec3Array): Vec3Array;
|
|
36
40
|
}
|
|
37
41
|
declare class VoxelSpace {
|
|
38
42
|
static bounds: Vector3Like;
|
package/World/WorldSpaces.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//types
|
|
2
2
|
import { EngineSettings } from "../Settings/EngineSettings.js";
|
|
3
3
|
import { Vector3Like } from "@amodx/math";
|
|
4
|
-
import { CubeHashVec3, CubeHashVec3Array, GetYXZOrderArrayIndex, GetYXZOrderArrayPositionVec3, } from "../Math/Indexing.js";
|
|
4
|
+
import { CubeHashVec3, CubeHashVec3Array, GetYXZOrderArrayIndex, GetYXZOrderArrayPositionVec3, GetYXZOrderArrayPositionVec3Array, } from "../Math/Indexing.js";
|
|
5
5
|
const tempPosition = Vector3Like.Create();
|
|
6
6
|
const tempPosition2 = Vector3Like.Create();
|
|
7
7
|
class WorldBounds {
|
|
@@ -57,6 +57,8 @@ class SectorSpace {
|
|
|
57
57
|
static power2Axes = Vector3Like.Create();
|
|
58
58
|
static bounds = Vector3Like.Create();
|
|
59
59
|
static volumne = 0;
|
|
60
|
+
static sectionBounds = Vector3Like.Create();
|
|
61
|
+
static sectionVolumne = 0;
|
|
60
62
|
static getPosition(x, y, z, refPosition = Vector3Like.Create()) {
|
|
61
63
|
CubeHashVec3(x, y, z, SectorSpace.power2Axes.x, SectorSpace.power2Axes.y, SectorSpace.power2Axes.z, refPosition);
|
|
62
64
|
return refPosition;
|
|
@@ -81,7 +83,13 @@ class SectionSpace {
|
|
|
81
83
|
static getIndex(x, y, z) {
|
|
82
84
|
SectionSpace.getPosition(x, y, z, tempPosition);
|
|
83
85
|
SectorSpace.getPosition(x, y, z, tempPosition2);
|
|
84
|
-
return (tempPosition.y - tempPosition2.y) / SectionSpace.bounds.y;
|
|
86
|
+
return GetYXZOrderArrayIndex((tempPosition.x - tempPosition2.x) / SectionSpace.bounds.x, (tempPosition.y - tempPosition2.y) / SectionSpace.bounds.y, (tempPosition.z - tempPosition2.z) / SectionSpace.bounds.z, SectorSpace.sectionBounds.x, SectorSpace.sectionBounds.y, SectorSpace.sectionBounds.z);
|
|
87
|
+
}
|
|
88
|
+
static getPositionFromIndex(index, refPosition = Vector3Like.Create()) {
|
|
89
|
+
return GetYXZOrderArrayPositionVec3(index, SectorSpace.sectionBounds.x, SectorSpace.sectionBounds.y, SectorSpace.sectionBounds.z, refPosition);
|
|
90
|
+
}
|
|
91
|
+
static getPositionFromIndexVec3Array(index, refPosition = [0, 0, 0]) {
|
|
92
|
+
return GetYXZOrderArrayPositionVec3Array(index, SectorSpace.sectionBounds.x, SectorSpace.sectionBounds.y, SectorSpace.sectionBounds.z, refPosition);
|
|
85
93
|
}
|
|
86
94
|
}
|
|
87
95
|
class VoxelSpace {
|
|
@@ -132,22 +140,27 @@ export class WorldSpaces {
|
|
|
132
140
|
EngineSettings.addEventListener("synced", (event) => {
|
|
133
141
|
const { settings } = event.detail.settings;
|
|
134
142
|
WorldBounds.setWorldBounds(settings.world.min.x, settings.world.min.y, settings.world.min.z, settings.world.max.x, settings.world.max.y, settings.world.max.z);
|
|
135
|
-
SectorSpace.power2Axes.x = settings.
|
|
136
|
-
SectorSpace.power2Axes.y = settings.
|
|
137
|
-
SectorSpace.power2Axes.z = settings.
|
|
143
|
+
SectorSpace.power2Axes.x = settings.world.sectorPower2Size.x;
|
|
144
|
+
SectorSpace.power2Axes.y = settings.world.sectorPower2Size.y;
|
|
145
|
+
SectorSpace.power2Axes.z = settings.world.sectorPower2Size.z;
|
|
138
146
|
SectorSpace.bounds.x = 1 << SectorSpace.power2Axes.x;
|
|
139
147
|
SectorSpace.bounds.y = 1 << SectorSpace.power2Axes.y;
|
|
140
148
|
SectorSpace.bounds.z = 1 << SectorSpace.power2Axes.z;
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
SectionSpace.power2Axes.
|
|
149
|
+
SectorSpace.volumne =
|
|
150
|
+
SectorSpace.bounds.x * SectorSpace.bounds.y * SectorSpace.bounds.z;
|
|
151
|
+
SectionSpace.power2Axes.x = settings.world.sectionPower2Size.x;
|
|
152
|
+
SectionSpace.power2Axes.y = settings.world.sectionPower2Size.y;
|
|
153
|
+
SectionSpace.power2Axes.z = settings.world.sectionPower2Size.z;
|
|
144
154
|
SectionSpace.bounds.x = 1 << SectionSpace.power2Axes.x;
|
|
145
155
|
SectionSpace.bounds.y = 1 << SectionSpace.power2Axes.y;
|
|
146
156
|
SectionSpace.bounds.z = 1 << SectionSpace.power2Axes.z;
|
|
147
157
|
SectionSpace.volumne =
|
|
148
158
|
SectionSpace.bounds.x * SectionSpace.bounds.y * SectionSpace.bounds.z;
|
|
149
|
-
SectorSpace.
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
159
|
+
SectorSpace.sectionBounds.x = SectorSpace.bounds.x / SectionSpace.bounds.x;
|
|
160
|
+
SectorSpace.sectionBounds.y = SectorSpace.bounds.y / SectionSpace.bounds.y;
|
|
161
|
+
SectorSpace.sectionBounds.z = SectorSpace.bounds.z / SectionSpace.bounds.z;
|
|
162
|
+
SectorSpace.sectionVolumne =
|
|
163
|
+
SectorSpace.sectionBounds.x *
|
|
164
|
+
SectorSpace.sectionBounds.y *
|
|
165
|
+
SectorSpace.sectionBounds.z;
|
|
153
166
|
});
|
|
@@ -20,7 +20,7 @@ declare class SectorQueue {
|
|
|
20
20
|
addSector(sector: Sector): void;
|
|
21
21
|
}
|
|
22
22
|
export declare class DimensionSegment {
|
|
23
|
-
id:
|
|
23
|
+
id: number;
|
|
24
24
|
tasks: Map<string, TaskSegment>;
|
|
25
25
|
queue: number[];
|
|
26
26
|
vistedMap: SectorVisistedMap;
|
|
@@ -28,7 +28,7 @@ export declare class DimensionSegment {
|
|
|
28
28
|
inProgress: SectorVisistedMap;
|
|
29
29
|
unRenderQueue: SectorQueue;
|
|
30
30
|
unLoadQueue: SectorQueue;
|
|
31
|
-
constructor(id:
|
|
31
|
+
constructor(id: number);
|
|
32
32
|
addTask(id: string): void;
|
|
33
33
|
getTask(id: string): TaskSegment;
|
|
34
34
|
clearAllTasks(): void;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { Vector3Like } from "@amodx/math";
|
|
2
2
|
import { Circle } from "@amodx/math/Shapes";
|
|
3
|
+
import { TaskTool } from "../../../Tools/Tasks/TasksTool";
|
|
4
|
+
import { BuildQueue } from "./Queues/BuildQueue";
|
|
5
|
+
import { LogicQueue } from "./Queues/LogiccQueue";
|
|
3
6
|
export interface GeneratorData {
|
|
4
|
-
dimension:
|
|
7
|
+
dimension: number;
|
|
5
8
|
building?: boolean;
|
|
6
9
|
culling?: boolean;
|
|
7
10
|
position: Vector3Like;
|
|
@@ -10,8 +13,9 @@ export interface GeneratorData {
|
|
|
10
13
|
maxRadius: number;
|
|
11
14
|
}
|
|
12
15
|
export declare class Generator {
|
|
16
|
+
taskTool: TaskTool;
|
|
13
17
|
position: Vector3Like;
|
|
14
|
-
_dimension:
|
|
18
|
+
_dimension: number;
|
|
15
19
|
_building: boolean;
|
|
16
20
|
_positonChanged: boolean;
|
|
17
21
|
_waitingForCull: boolean;
|
|
@@ -22,6 +26,9 @@ export declare class Generator {
|
|
|
22
26
|
_genCircle: Circle;
|
|
23
27
|
_renderCircle: Circle;
|
|
24
28
|
_maxCircle: Circle;
|
|
25
|
-
|
|
29
|
+
buildQueue: BuildQueue;
|
|
30
|
+
logicQueue: LogicQueue;
|
|
31
|
+
constructor(taskTool: TaskTool, data: GeneratorData);
|
|
26
32
|
update(): void;
|
|
33
|
+
tick(): void;
|
|
27
34
|
}
|