@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
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { WorldSimulation } from "../WorldSimulation";
|
|
2
|
+
import { WorldSimulationDimensions } from "../Internal/WorldSimulationDimensions";
|
|
3
|
+
import { WorldSimulationTools } from "../Internal/WorldSimulationTools";
|
|
4
4
|
import SaveAllSectors from "./SaveAllSectors";
|
|
5
5
|
/**# InitalLoad
|
|
6
6
|
* ---
|
|
@@ -8,23 +8,23 @@ import SaveAllSectors from "./SaveAllSectors";
|
|
|
8
8
|
*/
|
|
9
9
|
export async function InitalLoad(props) {
|
|
10
10
|
return new Promise((resolve) => {
|
|
11
|
-
const generator =
|
|
11
|
+
const generator = WorldSimulation.createGenerator({
|
|
12
12
|
...props.genData,
|
|
13
13
|
building: false,
|
|
14
14
|
culling: false
|
|
15
15
|
});
|
|
16
|
-
if (!
|
|
17
|
-
|
|
16
|
+
if (!WorldSimulationDimensions._dimensions.has(generator._dimension)) {
|
|
17
|
+
WorldSimulationDimensions.addDimension(generator._dimension);
|
|
18
18
|
}
|
|
19
|
-
const dimension =
|
|
19
|
+
const dimension = WorldSimulationDimensions.getDimension(props.dimension || 0);
|
|
20
20
|
let done = false;
|
|
21
21
|
generator._building = false;
|
|
22
|
-
|
|
22
|
+
WorldSimulation.addGenerator(generator);
|
|
23
23
|
let timeOut = null;
|
|
24
24
|
const update = () => {
|
|
25
25
|
if (done)
|
|
26
26
|
return;
|
|
27
|
-
|
|
27
|
+
WorldSimulation.update();
|
|
28
28
|
timeOut = setTimeout(update, 0);
|
|
29
29
|
};
|
|
30
30
|
update();
|
|
@@ -41,9 +41,9 @@ export async function InitalLoad(props) {
|
|
|
41
41
|
done = true;
|
|
42
42
|
clearInterval(inte);
|
|
43
43
|
clearTimeout(timeOut);
|
|
44
|
-
|
|
44
|
+
WorldSimulation.removeGenerator(generator);
|
|
45
45
|
(async () => {
|
|
46
|
-
if (
|
|
46
|
+
if (WorldSimulationTools.worldStorage) {
|
|
47
47
|
await SaveAllSectors();
|
|
48
48
|
}
|
|
49
49
|
resolve(true);
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import { WorldRegister } from "
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { WorldRegister } from "../../World/WorldRegister";
|
|
2
|
+
import { WorldSimulationDimensions } from "../Internal/WorldSimulationDimensions";
|
|
3
|
+
import { WorldSimulationTools } from "../Internal/WorldSimulationTools";
|
|
4
4
|
/**# Save All Sectors
|
|
5
5
|
* ---
|
|
6
6
|
* Save all sectors that are loaded.
|
|
7
7
|
*/
|
|
8
8
|
export default async function SaveAllSectors() {
|
|
9
|
-
const worldStorage =
|
|
9
|
+
const worldStorage = WorldSimulationTools.worldStorage;
|
|
10
10
|
if (!worldStorage)
|
|
11
11
|
return;
|
|
12
12
|
const proms = [];
|
|
13
|
-
for (const [dimensionId] of
|
|
13
|
+
for (const [dimensionId] of WorldSimulationDimensions._dimensions) {
|
|
14
14
|
const dimension = WorldRegister.dimensions.get(dimensionId);
|
|
15
15
|
for (const [key, sector] of dimension.sectors) {
|
|
16
|
+
if (sector.isStored())
|
|
17
|
+
continue;
|
|
16
18
|
proms.push(worldStorage.saveSector([dimensionId, ...sector.position]));
|
|
17
19
|
}
|
|
18
20
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Thread, ThreadPool } from "@amodx/threads";
|
|
2
|
-
import { WorldStorageInterface } from "
|
|
2
|
+
import { WorldStorageInterface } from "../World/Types/WorldStorage.interface";
|
|
3
3
|
import { Generator, GeneratorData } from "./Internal/Classes/Generator";
|
|
4
4
|
import { InitalLoad } from "./Procedures/InitalLoad";
|
|
5
5
|
import SaveAllSectors from "./Procedures/SaveAllSectors";
|
|
6
|
-
interface
|
|
6
|
+
interface WorldSimulationInitData {
|
|
7
7
|
parent: Thread;
|
|
8
8
|
threads: Thread | ThreadPool;
|
|
9
9
|
worldStorage?: WorldStorageInterface;
|
|
@@ -11,18 +11,19 @@ interface IWGInitData {
|
|
|
11
11
|
/**# Infinite World Generation IWG
|
|
12
12
|
* Object to handle the loading and generating the world around a created generator.
|
|
13
13
|
*/
|
|
14
|
-
export declare class
|
|
14
|
+
export declare class WorldSimulation {
|
|
15
15
|
private static _cullGenerators;
|
|
16
16
|
static readonly _generators: Generator[];
|
|
17
|
-
static addDimension(id:
|
|
17
|
+
static addDimension(id: number): void;
|
|
18
18
|
static Procedures: {
|
|
19
19
|
InitalLoad: typeof InitalLoad;
|
|
20
20
|
SaveAllSectors: typeof SaveAllSectors;
|
|
21
21
|
};
|
|
22
|
-
static init(data:
|
|
22
|
+
static init(data: WorldSimulationInitData): void;
|
|
23
23
|
static createGenerator(data: Partial<GeneratorData>): Generator;
|
|
24
24
|
static addGenerator(generator: Generator): void;
|
|
25
25
|
static removeGenerator(generator: Generator): boolean;
|
|
26
|
+
static tick(): void;
|
|
26
27
|
static update(): void;
|
|
27
28
|
}
|
|
28
29
|
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { TaskTool } from "
|
|
1
|
+
import { TaskTool } from "../Tools/Tasks/TasksTool";
|
|
2
2
|
import { Generator } from "./Internal/Classes/Generator";
|
|
3
3
|
import { runWorldUpdate } from "./Internal/Functions/runWorldUpdate";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
4
|
+
import { WorldSimulationTasks } from "./Internal/WorldSimulationTasks";
|
|
5
|
+
import { runTickUpdate } from "./Internal/Functions/runTickUpdate";
|
|
6
|
+
import { WorldSimulationTools } from "./Internal/WorldSimulationTools";
|
|
7
|
+
import { WorldSimulationDimensions } from "./Internal/WorldSimulationDimensions";
|
|
8
8
|
import { cullSectors } from "./Internal/Functions/cullSectors";
|
|
9
9
|
import { Vector3Like } from "@amodx/math";
|
|
10
10
|
import { InitalLoad } from "./Procedures/InitalLoad";
|
|
@@ -13,11 +13,11 @@ let initalized = false;
|
|
|
13
13
|
/**# Infinite World Generation IWG
|
|
14
14
|
* Object to handle the loading and generating the world around a created generator.
|
|
15
15
|
*/
|
|
16
|
-
export class
|
|
16
|
+
export class WorldSimulation {
|
|
17
17
|
static _cullGenerators = [];
|
|
18
18
|
static _generators = [];
|
|
19
19
|
static addDimension(id) {
|
|
20
|
-
|
|
20
|
+
WorldSimulationDimensions.addDimension(id);
|
|
21
21
|
}
|
|
22
22
|
static Procedures = {
|
|
23
23
|
InitalLoad,
|
|
@@ -25,15 +25,16 @@ export class IWG {
|
|
|
25
25
|
};
|
|
26
26
|
static init(data) {
|
|
27
27
|
initalized = true;
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
WorldSimulationTools.parent = data.parent;
|
|
29
|
+
WorldSimulationTools.taskTool = new TaskTool(data.threads);
|
|
30
30
|
if (data.worldStorage)
|
|
31
|
-
|
|
32
|
-
console.warn("load the thing", IWGTools.worldStorage, data.worldStorage);
|
|
31
|
+
WorldSimulationTools.worldStorage = data.worldStorage;
|
|
33
32
|
}
|
|
34
33
|
static createGenerator(data) {
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
if (!initalized)
|
|
35
|
+
throw new Error(`IWG must be initalized first before creating generator`);
|
|
36
|
+
return new Generator(WorldSimulationTools.taskTool, {
|
|
37
|
+
dimension: data.dimension ? data.dimension : 0,
|
|
37
38
|
position: data.position ? data.position : Vector3Like.Create(),
|
|
38
39
|
renderRadius: data.renderRadius ? data.renderRadius : 150,
|
|
39
40
|
generationRadius: data.generationRadius ? data.generationRadius : 250,
|
|
@@ -53,6 +54,11 @@ export class IWG {
|
|
|
53
54
|
}
|
|
54
55
|
return false;
|
|
55
56
|
}
|
|
57
|
+
static tick() {
|
|
58
|
+
for (const gen of this._generators) {
|
|
59
|
+
gen.tick();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
56
62
|
static update() {
|
|
57
63
|
if (!initalized) {
|
|
58
64
|
throw new Error(`IWG must be initalized.`);
|
|
@@ -76,17 +82,17 @@ export class IWG {
|
|
|
76
82
|
}
|
|
77
83
|
}
|
|
78
84
|
}
|
|
79
|
-
|
|
80
|
-
IWGTasks.buildTasks.runTask();
|
|
85
|
+
runTickUpdate(this._generators);
|
|
86
|
+
// IWGTasks.buildTasks.runTask();
|
|
81
87
|
runWorldUpdate(this._generators);
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
WorldSimulationTasks.worldLoadTasks.runTask();
|
|
89
|
+
WorldSimulationTasks.worldGenTasks.runTask();
|
|
90
|
+
WorldSimulationTasks.worldDecorateTasks.runTask();
|
|
91
|
+
WorldSimulationTasks.worldSunTasks.runTask();
|
|
92
|
+
WorldSimulationTasks.worldPropagationTasks.runTask();
|
|
93
|
+
WorldSimulationTasks.saveTasks.runTask();
|
|
94
|
+
WorldSimulationTasks.saveAndUnloadTasks.runTask();
|
|
89
95
|
cullSectors(this._generators, this._cullGenerators);
|
|
90
96
|
}
|
|
91
97
|
}
|
|
92
|
-
|
|
98
|
+
WorldSimulation.addDimension(0);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./
|
|
1
|
+
export * from "./WorldSimulation";
|
|
2
2
|
export * from "./Procedures/InitalLoad";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./
|
|
1
|
+
export * from "./WorldSimulation";
|
|
2
2
|
export * from "./Procedures/InitalLoad";
|
package/package.json
CHANGED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
export function CompactMesh(materialId, tool) {
|
|
2
|
-
/* let webGPU = EngineSettings.settings.rendererSettings.mode == "webgpu";
|
|
3
|
-
|
|
4
|
-
const mesh = tool.mesh!;
|
|
5
|
-
const byteRanges: [
|
|
6
|
-
byteStart: number,
|
|
7
|
-
length: number,
|
|
8
|
-
type: BinaryNumberTypes,
|
|
9
|
-
][] = [];
|
|
10
|
-
const dataMap: CompactSubMesh = [materialId, []];
|
|
11
|
-
let totalSize = 0;
|
|
12
|
-
for (let [key, [array, stride, type]] of mesh.attributes) {
|
|
13
|
-
if (key == MeshDefaultAttributes.Indices) {
|
|
14
|
-
if (array.length > 60_000) {
|
|
15
|
-
type = BinaryNumberTypes.Uint32;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
let current = totalSize;
|
|
19
|
-
|
|
20
|
-
totalSize += MappedByteCounts[type] * array.length;
|
|
21
|
-
byteRanges.push([current, array.length, type]);
|
|
22
|
-
dataMap[1].push([key, array as any, stride]);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const finalBuffer = new ArrayBuffer(totalSize);
|
|
26
|
-
|
|
27
|
-
for (let i = 0; i < dataMap[1].length; i++) {
|
|
28
|
-
const startByte = byteRanges[i][0];
|
|
29
|
-
const length = byteRanges[i][1];
|
|
30
|
-
const type = byteRanges[i][2];
|
|
31
|
-
const newArray = new TypedArrayClassMap[type](
|
|
32
|
-
finalBuffer,
|
|
33
|
-
//@ts-ignore
|
|
34
|
-
startByte,
|
|
35
|
-
length
|
|
36
|
-
) as Float32Array;
|
|
37
|
-
newArray.set(dataMap[1][i][0] as any as number[]);
|
|
38
|
-
dataMap[1][i][1] = newArray;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return [0, finalBuffer, [dataMap]]; */
|
|
42
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Vec3Array } from "@amodx/math";
|
|
2
|
-
export declare class GeometryNormals {
|
|
3
|
-
static subtract(v1: Vec3Array, v2: Vec3Array): Vec3Array;
|
|
4
|
-
static cross(v1: Vec3Array, v2: Vec3Array): Vec3Array;
|
|
5
|
-
static scale(v: Vec3Array, scaleFactor: number): Vec3Array;
|
|
6
|
-
static add(v1: Vec3Array, v2: Vec3Array): Vec3Array;
|
|
7
|
-
static normalize(v: Vec3Array): Vec3Array;
|
|
8
|
-
static getTriangleNormals(p1: Vec3Array, p2: Vec3Array, p3: Vec3Array): Vec3Array;
|
|
9
|
-
static getQuadNormal(p1: Vec3Array, p2: Vec3Array, p3: Vec3Array, p4: Vec3Array): [n1: Vec3Array, n2: Vec3Array, n3: Vec3Array, n4: Vec3Array];
|
|
10
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
export class GeometryNormals {
|
|
2
|
-
static subtract(v1, v2) {
|
|
3
|
-
return [v1[0] - v2[0], v1[1] - v2[1], v1[2] - v2[2]];
|
|
4
|
-
}
|
|
5
|
-
static cross(v1, v2) {
|
|
6
|
-
return [
|
|
7
|
-
v1[1] * v2[2] - v1[2] * v2[1],
|
|
8
|
-
v1[2] * v2[0] - v1[0] * v2[2],
|
|
9
|
-
v1[0] * v2[1] - v1[1] * v2[0],
|
|
10
|
-
];
|
|
11
|
-
}
|
|
12
|
-
static scale(v, scaleFactor) {
|
|
13
|
-
return [v[0] * scaleFactor, v[1] * scaleFactor, v[2] * scaleFactor];
|
|
14
|
-
}
|
|
15
|
-
static add(v1, v2) {
|
|
16
|
-
return [v1[0] + v2[0], v1[1] + v2[1], v1[2] + v2[2]];
|
|
17
|
-
}
|
|
18
|
-
static normalize(v) {
|
|
19
|
-
const length = Math.sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
|
|
20
|
-
return length > 0
|
|
21
|
-
? [v[0] / length, v[1] / length, v[2] / length]
|
|
22
|
-
: [0, 0, 0];
|
|
23
|
-
}
|
|
24
|
-
static getTriangleNormals(p1, p2, p3) {
|
|
25
|
-
const a = this.subtract(p2, p1);
|
|
26
|
-
const b = this.subtract(p3, p1);
|
|
27
|
-
const substract = this.cross(a, b);
|
|
28
|
-
const normal = this.scale(substract, -1);
|
|
29
|
-
return this.normalize(normal);
|
|
30
|
-
}
|
|
31
|
-
static getQuadNormal(p1, p2, p3, p4) {
|
|
32
|
-
const vectorA1 = [p2[0] - p1[0], p2[1] - p1[1], p2[2] - p1[2]];
|
|
33
|
-
const vectorA2 = [p3[0] - p1[0], p3[1] - p1[1], p3[2] - p1[2]];
|
|
34
|
-
const normalA = this.normalize(this.cross(vectorA1, vectorA2));
|
|
35
|
-
const vectorB1 = [p3[0] - p1[0], p3[1] - p1[1], p3[2] - p1[2]];
|
|
36
|
-
const vectorB2 = [p4[0] - p1[0], p4[1] - p1[1], p4[2] - p1[2]];
|
|
37
|
-
const normalB = this.normalize(this.cross(vectorB1, vectorB2));
|
|
38
|
-
const n1 = this.normalize([
|
|
39
|
-
(normalA[0] + normalB[0]) / 2,
|
|
40
|
-
(normalA[1] + normalB[1]) / 2,
|
|
41
|
-
(normalA[2] + normalB[2]) / 2,
|
|
42
|
-
]);
|
|
43
|
-
const n2 = normalA;
|
|
44
|
-
const n3 = this.normalize([
|
|
45
|
-
(normalA[0] + normalB[0]) / 2,
|
|
46
|
-
(normalA[1] + normalB[1]) / 2,
|
|
47
|
-
(normalA[2] + normalB[2]) / 2,
|
|
48
|
-
]);
|
|
49
|
-
const n4 = normalB;
|
|
50
|
-
return [n1, n2, n3, n4];
|
|
51
|
-
}
|
|
52
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { TypedArrays } from "@amodx/binary";
|
|
2
|
-
export declare enum MeshDefaultAttributes {
|
|
3
|
-
Position = "position",
|
|
4
|
-
Normal = "normal",
|
|
5
|
-
Indices = "indices"
|
|
6
|
-
}
|
|
7
|
-
export type MeshAttributes = [
|
|
8
|
-
id: string,
|
|
9
|
-
data: TypedArrays,
|
|
10
|
-
stride: number,
|
|
11
|
-
componentTypes?: number,
|
|
12
|
-
noramlizer?: number
|
|
13
|
-
][];
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export var MeshDefaultAttributes;
|
|
2
|
-
(function (MeshDefaultAttributes) {
|
|
3
|
-
MeshDefaultAttributes["Position"] = "position";
|
|
4
|
-
MeshDefaultAttributes["Normal"] = "normal";
|
|
5
|
-
MeshDefaultAttributes["Indices"] = "indices";
|
|
6
|
-
})(MeshDefaultAttributes || (MeshDefaultAttributes = {}));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./MesherDataTools.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./MesherDataTools.js";
|
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
import { WorldSpaces } from "../../World/WorldSpaces";
|
|
2
|
-
const MAX_FLOAT32 = new Float32Array([Infinity])[0];
|
|
3
|
-
/**
|
|
4
|
-
* A class to help with indexing a full flat binary tree defined by the number of levels it has.
|
|
5
|
-
*/
|
|
6
|
-
class FlatBinaryTreeIndex {
|
|
7
|
-
levels;
|
|
8
|
-
constructor(levels) {
|
|
9
|
-
this.levels = levels;
|
|
10
|
-
}
|
|
11
|
-
/** Gets the number of nodes at a level of the tree */
|
|
12
|
-
getLevelSize(level) {
|
|
13
|
-
if (level < 0 || level >= this.levels) {
|
|
14
|
-
throw new Error("Invalid level");
|
|
15
|
-
}
|
|
16
|
-
return 1 << level; // Equivalent to 2^level
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Gets the flat index of a node indexed by the level it's on and its relative index in that level.
|
|
20
|
-
*/
|
|
21
|
-
getIndexAtLevel(level, node) {
|
|
22
|
-
if (level < 0 || level >= this.levels) {
|
|
23
|
-
throw new Error("Invalid level");
|
|
24
|
-
}
|
|
25
|
-
const levelSize = this.getLevelSize(level);
|
|
26
|
-
if (node < 0 || node >= levelSize) {
|
|
27
|
-
throw new Error("Invalid node index at the given level");
|
|
28
|
-
}
|
|
29
|
-
return (1 << level) - 1 + node;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Gets the level and relative index of a node's flat index.
|
|
33
|
-
*/
|
|
34
|
-
getLevelAndIndex(index) {
|
|
35
|
-
const totalNodes = (1 << this.levels) - 1;
|
|
36
|
-
if (index < 0 || index >= totalNodes) {
|
|
37
|
-
throw new Error("Invalid node index");
|
|
38
|
-
}
|
|
39
|
-
const level = Math.floor(Math.log2(index + 1));
|
|
40
|
-
const firstIndexAtLevel = (1 << level) - 1;
|
|
41
|
-
const relativeIndex = index - firstIndexAtLevel;
|
|
42
|
-
return [level, relativeIndex];
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Gets the flat left child of a node, where the node is indexed by its level and its relative index at that level.
|
|
46
|
-
* @returns -1 if no child exist
|
|
47
|
-
*/
|
|
48
|
-
getLeftChildAtLevel(level, node) {
|
|
49
|
-
if (level + 1 >= this.levels) {
|
|
50
|
-
return -1;
|
|
51
|
-
}
|
|
52
|
-
const nodeIndex = this.getIndexAtLevel(level, node);
|
|
53
|
-
return this.getLeftChild(nodeIndex);
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Gets the flat right child of a node, where the node is indexed by its level and its relative index at that level.
|
|
57
|
-
* @returns -1 if no child exist
|
|
58
|
-
*/
|
|
59
|
-
getRightChildAtLevel(level, node) {
|
|
60
|
-
if (level + 1 >= this.levels) {
|
|
61
|
-
return -1;
|
|
62
|
-
}
|
|
63
|
-
const nodeIndex = this.getIndexAtLevel(level, node);
|
|
64
|
-
return this.getRightChild(nodeIndex);
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Gets the flat index of the parent of a node, where the node is indexed by its level and its relative index at that level.
|
|
68
|
-
* @returns -1 if level has no parent
|
|
69
|
-
*/
|
|
70
|
-
getParentAtLevel(level, node) {
|
|
71
|
-
if (level === 0) {
|
|
72
|
-
return -1;
|
|
73
|
-
}
|
|
74
|
-
const nodeIndex = this.getIndexAtLevel(level, node);
|
|
75
|
-
return this.getParent(nodeIndex);
|
|
76
|
-
}
|
|
77
|
-
/** Gets the flat index of the left child of the node.
|
|
78
|
-
* @returns -1 if no child exist
|
|
79
|
-
*/
|
|
80
|
-
getLeftChild(node) {
|
|
81
|
-
const leftChildIndex = 2 * node + 1;
|
|
82
|
-
const totalNodes = (1 << this.levels) - 1;
|
|
83
|
-
return leftChildIndex < totalNodes ? leftChildIndex : -1;
|
|
84
|
-
}
|
|
85
|
-
/** Gets the flat index of the right child of the node.
|
|
86
|
-
* @returns -1 if no child exist
|
|
87
|
-
*/
|
|
88
|
-
getRightChild(node) {
|
|
89
|
-
const rightChildIndex = 2 * node + 2;
|
|
90
|
-
const totalNodes = (1 << this.levels) - 1;
|
|
91
|
-
return rightChildIndex < totalNodes ? rightChildIndex : -1;
|
|
92
|
-
}
|
|
93
|
-
/** Gets the flat index of the parent of the node.
|
|
94
|
-
* @returns -1 if no parent exist
|
|
95
|
-
*/
|
|
96
|
-
getParent(node) {
|
|
97
|
-
if (node === 0) {
|
|
98
|
-
return -1; // Root node has no parent
|
|
99
|
-
}
|
|
100
|
-
return Math.floor((node - 1) / 2);
|
|
101
|
-
}
|
|
102
|
-
/** Gets the total number of nodes in the tree */
|
|
103
|
-
getTotalSize() {
|
|
104
|
-
return (1 << this.levels) - 1; // Equivalent to 2^levels - 1
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
export class StructCursor {
|
|
108
|
-
data;
|
|
109
|
-
get minX() {
|
|
110
|
-
return this.data[this.trueIndex];
|
|
111
|
-
}
|
|
112
|
-
get minY() {
|
|
113
|
-
return this.data[this.trueIndex + 1];
|
|
114
|
-
}
|
|
115
|
-
get minZ() {
|
|
116
|
-
return this.data[this.trueIndex + 2];
|
|
117
|
-
}
|
|
118
|
-
get maxX() {
|
|
119
|
-
return this.data[this.trueIndex + 4];
|
|
120
|
-
}
|
|
121
|
-
get maxY() {
|
|
122
|
-
return this.data[this.trueIndex + 5];
|
|
123
|
-
}
|
|
124
|
-
get maxZ() {
|
|
125
|
-
return this.data[this.trueIndex + 6];
|
|
126
|
-
}
|
|
127
|
-
get voxelIndex() {
|
|
128
|
-
return this.data[this.trueIndex + 3];
|
|
129
|
-
}
|
|
130
|
-
get active() {
|
|
131
|
-
return this.data[this.trueIndex + 3];
|
|
132
|
-
}
|
|
133
|
-
get nodeType() {
|
|
134
|
-
return this.data[this.trueIndex + 7];
|
|
135
|
-
}
|
|
136
|
-
trueIndex = 0;
|
|
137
|
-
index = 0;
|
|
138
|
-
setIndex(index) {
|
|
139
|
-
this.trueIndex = index * 8;
|
|
140
|
-
}
|
|
141
|
-
constructor(data) {
|
|
142
|
-
this.data = data;
|
|
143
|
-
}
|
|
144
|
-
setActive() {
|
|
145
|
-
this.data[this.trueIndex + 3] = 1;
|
|
146
|
-
}
|
|
147
|
-
setVoxelIndex(value) {
|
|
148
|
-
this.data[this.trueIndex + 3] = value;
|
|
149
|
-
}
|
|
150
|
-
setInnerNode() {
|
|
151
|
-
this.data[this.trueIndex + 7] = 1;
|
|
152
|
-
}
|
|
153
|
-
setGeomtryNode() {
|
|
154
|
-
this.data[this.trueIndex + 7] = 2;
|
|
155
|
-
}
|
|
156
|
-
updateMin(x, y, z) {
|
|
157
|
-
const ix = this.trueIndex;
|
|
158
|
-
const iy = this.trueIndex + 1;
|
|
159
|
-
const iz = this.trueIndex + 2;
|
|
160
|
-
if (x < this.data[ix] || this.data[ix] == -MAX_FLOAT32) {
|
|
161
|
-
this.data[ix] = x;
|
|
162
|
-
}
|
|
163
|
-
if (y < this.data[iy] || this.data[iy] == -MAX_FLOAT32) {
|
|
164
|
-
this.data[iy] = y;
|
|
165
|
-
}
|
|
166
|
-
if (z < this.data[iz] || this.data[iz] == -MAX_FLOAT32) {
|
|
167
|
-
this.data[iz] = z;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
updateMax(x, y, z) {
|
|
171
|
-
const ix = this.trueIndex + 4;
|
|
172
|
-
const iy = this.trueIndex + 5;
|
|
173
|
-
const iz = this.trueIndex + 6;
|
|
174
|
-
if (x > this.data[ix] || this.data[ix] == -MAX_FLOAT32) {
|
|
175
|
-
this.data[ix] = x;
|
|
176
|
-
}
|
|
177
|
-
if (y > this.data[iy] || this.data[iy] == -MAX_FLOAT32) {
|
|
178
|
-
this.data[iy] = y;
|
|
179
|
-
}
|
|
180
|
-
if (z > this.data[iz] || this.data[iz] == -MAX_FLOAT32) {
|
|
181
|
-
this.data[iz] = z;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
export class VoxelMeshBVHBuilder {
|
|
186
|
-
static AABBStructByteSize = (4 + 4) * 4;
|
|
187
|
-
treeIndex = new FlatBinaryTreeIndex(13);
|
|
188
|
-
tree = new Float32Array(new ArrayBuffer(this.treeIndex.getTotalSize() * VoxelMeshBVHBuilder.AABBStructByteSize));
|
|
189
|
-
structCursor = new StructCursor(this.tree);
|
|
190
|
-
indices = new Uint32Array(this.treeIndex.getLevelSize(12) * 2);
|
|
191
|
-
reset() {
|
|
192
|
-
this.tree.fill(-MAX_FLOAT32);
|
|
193
|
-
this.indices.fill(0);
|
|
194
|
-
}
|
|
195
|
-
updateVoxel(voxelX, voxelY, voxelZ, meshIndex, indicesStart, indicesEnd, minX, minY, minZ, maxX, maxY, maxZ) {
|
|
196
|
-
const voxelIndex = WorldSpaces.voxel.getIndex(voxelX, voxelY, voxelZ);
|
|
197
|
-
const leafIndex = this.treeIndex.getIndexAtLevel(12, voxelIndex);
|
|
198
|
-
this.indices[voxelIndex * 2] = indicesStart;
|
|
199
|
-
this.indices[voxelIndex * 2 + 1] = indicesEnd;
|
|
200
|
-
this.structCursor.setIndex(leafIndex);
|
|
201
|
-
this.structCursor.updateMin(minX, minY, minZ);
|
|
202
|
-
this.structCursor.updateMax(maxX, maxY, maxZ);
|
|
203
|
-
this.structCursor.setVoxelIndex(voxelIndex);
|
|
204
|
-
this.structCursor.setGeomtryNode();
|
|
205
|
-
let current = leafIndex;
|
|
206
|
-
for (let level = 1; level < 13; level++) {
|
|
207
|
-
let parentNode = this.treeIndex.getParent(current);
|
|
208
|
-
this.structCursor.setIndex(parentNode);
|
|
209
|
-
this.structCursor.updateMin(minX, minY, minZ);
|
|
210
|
-
this.structCursor.updateMax(maxX, maxY, maxZ);
|
|
211
|
-
this.structCursor.setActive();
|
|
212
|
-
this.structCursor.setInnerNode();
|
|
213
|
-
current = parentNode;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|