@divinevoxel/vlox 0.0.71 → 0.0.73
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/Main/InitDataGenerator.js +0 -9
- package/Contexts/Base/Remote/DataSync.types.d.ts +0 -5
- package/Contexts/Base/Remote/InitDataSync.js +17 -31
- package/Contexts/Render/DivineVoxelEngineRender.d.ts +1 -1
- package/Contexts/World/DivineVoxelEngineWorld.d.ts +1 -1
- package/Init/StartConstructor.js +7 -7
- package/Init/StartWorld.d.ts +1 -1
- package/Init/StartWorld.js +0 -12
- package/Math/Indexing.d.ts +12 -3
- package/Math/Indexing.js +24 -15
- package/Mesher/Functions/CompactVoxelMesh.d.ts +2 -2
- package/Mesher/Functions/CompactVoxelMesh.js +4 -5
- package/Mesher/Functions/MeshSection.d.ts +1 -1
- package/Mesher/Functions/MeshSection.js +72 -66
- package/Mesher/Functions/MeshTexture.d.ts +1 -1
- package/Mesher/Functions/MeshTexture.js +3 -4
- package/Mesher/Functions/MeshVoxel.js +20 -26
- 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 +108 -125
- package/Mesher/Geomtry/VoxelMesh.d.ts +1 -1
- package/Mesher/Geomtry/VoxelMesh.js +2 -2
- package/Mesher/{Tools → Geomtry}/VoxelMeshBVHBuilder.d.ts +2 -9
- package/Mesher/{Tools → Geomtry}/VoxelMeshBVHBuilder.js +4 -16
- package/Mesher/Geomtry/{Buffers.d.ts → VoxelMeshBuffers.d.ts} +9 -8
- package/Mesher/Geomtry/VoxelMeshBuffers.js +49 -0
- package/Mesher/{Tools → Geomtry}/VoxelMeshVertexStructCursor.d.ts +10 -0
- package/Mesher/{Tools → Geomtry}/VoxelMeshVertexStructCursor.js +10 -0
- package/Mesher/Geomtry/index.d.ts +0 -1
- package/Mesher/Geomtry/index.js +0 -1
- package/Mesher/InitMesher.js +2 -11
- package/Mesher/InitTask.js +10 -22
- package/Mesher/Models/Common/BoundsFunctions.d.ts +1 -3
- package/Mesher/Models/Common/BoundsFunctions.js +0 -16
- package/Mesher/Models/Common/Calc/CalcConstants.js +14 -31
- package/Mesher/Models/Common/Calc/FaceDataCalc.d.ts +2 -8
- package/Mesher/Models/Common/Calc/FaceDataCalc.js +50 -52
- 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.d.ts +1 -5
- package/Mesher/Models/Nodes/Custom/Liquid/LiquidGeomtryNode.js +40 -42
- package/Mesher/Models/Nodes/GeometryNode.d.ts +3 -5
- package/Mesher/Models/Nodes/GeometryNode.js +1 -2
- package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.d.ts +3 -6
- package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.js +55 -40
- package/Mesher/Models/Nodes/Ruled/QuadVoxelGeometryNode.d.ts +2 -6
- package/Mesher/Models/Nodes/Ruled/QuadVoxelGeometryNode.js +52 -51
- package/Mesher/Models/Nodes/Ruleless/RulelessBoxVoxelGeometryNode.d.ts +2 -6
- package/Mesher/Models/Nodes/Ruleless/RulelessBoxVoxelGeometryNode.js +18 -19
- package/Mesher/Models/Nodes/Ruleless/RulelessQuadVoxelGeometryNode.d.ts +2 -6
- package/Mesher/Models/Nodes/Ruleless/RulelessQuadVoxelGeometryNode.js +37 -40
- 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 +4 -5
- package/Mesher/Models/VoxelConstructor.js +23 -12
- package/Mesher/Models/{VoxelGeometryLookUp.d.ts → VoxelGeometryBuilderCacheSpace.d.ts} +6 -14
- package/Mesher/Models/{VoxelGeometryLookUp.js → VoxelGeometryBuilderCacheSpace.js} +26 -44
- package/Mesher/{Tools/VoxelMesherDataTool.d.ts → Models/VoxelModelBuilder.d.ts} +10 -8
- package/Mesher/{Tools/VoxelMesherDataTool.js → Models/VoxelModelBuilder.js} +44 -19
- package/Mesher/Models/VoxelModelConstructorRegister.js +3 -3
- package/Models/Defaults/CubeVoxelGeometry.js +4 -0
- package/Models/Defaults/CubeVoxelModels.js +344 -344
- package/Models/Defaults/LiquidVoxelModel.js +2 -2
- package/Models/Defaults/PanelVoxelModels.js +432 -432
- package/Models/Defaults/StairVoxelModel.js +576 -576
- package/Models/Examples.js +469 -456
- package/Models/Indexing/VoxelAOResultsIndex.d.ts +4 -4
- package/Models/Indexing/VoxelAOResultsIndex.js +15 -9
- package/Models/Indexing/VoxelFaceCullResultsIndex.d.ts +3 -3
- package/Models/Indexing/VoxelFaceCullResultsIndex.js +14 -9
- package/Models/Indexing/VoxelFaceTransparentResultsIndex.d.ts +1 -1
- package/Models/Indexing/VoxelFaceTransparentResultsIndex.js +1 -1
- package/Models/Rules/Functions/BuildFinalInputs.js +9 -7
- package/Models/Rules/Functions/BuildGeomtryInputs.js +8 -5
- package/Models/Rules/Functions/BuildRules.js +4 -4
- package/Models/Rules/{VoxelModelManager.d.ts → VoxelModelRuleBuilderRegister.d.ts} +1 -1
- package/Models/Rules/VoxelModelRuleBuilderRegister.js +178 -0
- package/Models/VoxelModel.types.d.ts +14 -5
- package/Renderer/Classes/SectorMesh.d.ts +3 -4
- package/Renderer/Classes/SectorMesh.js +6 -11
- package/Renderer/InitTasks.js +6 -7
- package/Renderer/MeshManager.js +2 -2
- package/Renderer/MeshRegister.js +2 -1
- package/Settings/EngineSettings.d.ts +1 -1
- package/Settings/EngineSettings.js +3 -5
- package/Settings/EngineSettings.types.d.ts +17 -18
- package/Settings/EngineSettings.types.js +16 -15
- package/Tasks/IWG/IWG.d.ts +2 -1
- package/Tasks/IWG/IWG.js +9 -3
- package/Tasks/IWG/Internal/Classes/BuildQueue.d.ts +11 -0
- package/Tasks/IWG/Internal/Classes/BuildQueue.js +49 -0
- package/Tasks/IWG/Internal/Classes/Generator.d.ts +6 -1
- package/Tasks/IWG/Internal/Classes/Generator.js +14 -2
- package/Tasks/IWG/Internal/Classes/IWGTaskBase.js +2 -2
- package/Tasks/IWG/Internal/Functions/getSectorState.js +4 -7
- package/Tasks/IWG/Internal/Functions/runBuildUpdate.js +21 -2
- package/Tasks/IWG/Internal/Functions/runWorldUpdate.js +5 -6
- package/Tasks/IWG/Internal/IWGTasks.d.ts +0 -4
- package/Tasks/IWG/Internal/IWGTasks.js +12 -31
- package/Tasks/IWG/Internal/IWGTools.d.ts +1 -1
- package/Tasks/IWG/Procedures/SaveAllSectors.js +2 -0
- package/Tasks/Propagation/Flow/FlowManager.d.ts +0 -2
- package/Tasks/Propagation/Flow/FlowManager.js +86 -87
- package/Tasks/Propagation/Flow/WorldFlow.js +2 -3
- package/Tasks/Propagation/Illumanation/WorldRGB.js +1 -2
- package/Tasks/Update/InitTasks.d.ts +2 -1
- package/Tasks/Update/InitTasks.js +6 -6
- package/Tasks/Update/UpdateTask.d.ts +3 -1
- package/Tasks/Update/UpdateTask.js +28 -2
- package/Tasks/Update/VoxelUpdate.js +21 -7
- package/Tasks/WorldGeneration/WorldGenBrush.js +2 -1
- package/Templates/Cursor/TemplateCursor.d.ts +2 -2
- package/Templates/Cursor/TemplateCursor.js +1 -2
- package/Templates/Functions/CreateTemplate.js +1 -1
- package/Templates/VoxelTemplate.js +6 -8
- 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/Brush.d.ts +1 -3
- package/Tools/Brush/Brush.js +43 -12
- package/Util/Binary/BinaryArrays.d.ts +6 -0
- package/Util/Binary/BinaryArrays.js +25 -0
- package/Util/Binary/BinaryBuffer.d.ts +29 -0
- package/Util/Binary/BinaryBuffer.js +130 -0
- package/Util/Binary/BinaryFunctions.d.ts +3 -0
- package/Util/Binary/BinaryFunctions.js +11 -0
- package/Util/StringPalette.d.ts +1 -0
- package/Util/StringPalette.js +8 -0
- package/Voxels/Cursor/DataCursor.interface.d.ts +5 -0
- package/Voxels/Cursor/VoxelCursor.d.ts +6 -6
- package/Voxels/Cursor/VoxelCursor.interface.d.ts +11 -16
- package/Voxels/Cursor/VoxelCursor.interface.js +35 -58
- package/Voxels/Cursor/VoxelCursor.js +13 -12
- package/Voxels/Cursor/VoxelLightData.d.ts +3 -4
- package/Voxels/Cursor/VoxelLightData.js +8 -7
- package/Voxels/Data/VoxelPalettesRegister.d.ts +8 -0
- package/Voxels/Data/VoxelPalettesRegister.js +8 -0
- package/Voxels/Data/VoxelTag.types.d.ts +56 -0
- package/Voxels/Data/VoxelTag.types.js +23 -0
- package/Voxels/{State → Data}/VoxelTagStates.d.ts +2 -2
- package/Voxels/{State → Data}/VoxelTagStates.js +5 -5
- package/Voxels/Data/VoxelTagsRegister.d.ts +9 -0
- package/Voxels/Data/VoxelTagsRegister.js +32 -0
- package/Voxels/Functions/BuildStateData.js +12 -12
- package/Voxels/Functions/BuildTagAndPaletteData.d.ts +13 -0
- package/Voxels/Functions/BuildTagAndPaletteData.js +55 -0
- package/Voxels/Indexes/VoxelIndex.js +3 -3
- package/Voxels/InitVoxelData.js +31 -73
- package/Voxels/State/Schema/StateSchema.d.ts +1 -1
- package/Voxels/Types/Voxel.types.d.ts +20 -42
- package/Voxels/Types/Voxel.types.js +6 -17
- package/Voxels/Types/VoxelModelCompiledData.types.d.ts +11 -13
- package/Voxels/Types/VoxelSubstances.types.d.ts +2 -15
- package/Voxels/Types/VoxelSubstances.types.js +1 -9
- package/World/Archive/Archive.types.d.ts +38 -34
- package/World/Archive/Functions/ArchiveArea.js +18 -30
- package/World/Archive/Functions/ArchiveSector.js +484 -213
- package/World/Archive/Functions/ImportSector.d.ts +3 -3
- package/World/Archive/Functions/ImportSector.js +205 -151
- package/World/Archive/Functions/Shared.d.ts +6 -0
- package/World/Archive/Functions/Shared.js +75 -0
- package/World/Archive/InitTasks.js +30 -13
- package/World/Cursor/SectionCursor.d.ts +3 -2
- package/World/Cursor/SectionCursor.js +9 -4
- package/World/Cursor/SectorCursor.d.ts +3 -2
- package/World/Cursor/SectorCursor.js +5 -3
- package/World/Cursor/WorldCursor.d.ts +2 -2
- package/World/Cursor/WorldCursor.js +6 -3
- package/World/Cursor/WorldVoxelCursor.d.ts +7 -7
- package/World/Cursor/WorldVoxelCursor.js +21 -24
- package/World/InitTasks.d.ts +1 -1
- package/World/Lock/WorldLock.d.ts +1 -1
- package/World/Section/Section.d.ts +31 -23
- package/World/Section/Section.js +116 -18
- package/World/Section/SectionState.d.ts +10 -0
- package/World/Section/SectionState.js +11 -0
- package/World/Sector/Sector.d.ts +24 -9
- package/World/Sector/Sector.js +92 -21
- package/World/Sector/SectorHeightMap.js +3 -5
- package/World/Sector/SectorState.d.ts +21 -0
- package/World/Sector/SectorState.js +28 -0
- package/World/WorldRegister.d.ts +4 -0
- package/World/WorldRegister.js +15 -3
- package/World/WorldSpaces.d.ts +6 -0
- package/World/WorldSpaces.js +25 -6
- package/package.json +1 -1
- package/Data/Cursor/DataCursor.interface.d.ts +0 -5
- package/Data/Cursor/DataCursor.interface.js +0 -2
- package/Data/Register/MappedDataRegister.d.ts +0 -5
- package/Data/Register/MappedDataRegister.js +0 -9
- package/Data/Register/MappedRegisterBase.d.ts +0 -14
- package/Data/Register/MappedRegisterBase.js +0 -50
- package/Data/Structs/StructBuilder.d.ts +0 -34
- package/Data/Structs/StructBuilder.js +0 -157
- package/Data/Structs/StructBuilder.types.d.ts +0 -30
- package/Mesher/Functions/CompactMesh.d.ts +0 -2
- package/Mesher/Functions/CompactMesh.js +0 -42
- package/Mesher/Geomtry/Buffers.js +0 -81
- 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/Models/Rules/VoxelModelManager.js +0 -82
- 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/Data/SubstanceDataTool.d.ts +0 -13
- package/Tools/Data/SubstanceDataTool.js +0 -51
- package/Voxels/Palettes/MaterialPalette.d.ts +0 -9
- package/Voxels/Palettes/MaterialPalette.js +0 -11
- package/Voxels/Palettes/SubstancePalette.d.ts +0 -9
- package/Voxels/Palettes/SubstancePalette.js +0 -11
- package/Voxels/Palettes/VoxelPalette.d.ts +0 -11
- package/Voxels/Palettes/VoxelPalette.js +0 -15
- package/Voxels/Segments/MaterialDataGenerator.d.ts +0 -6
- package/Voxels/Segments/MaterialDataGenerator.js +0 -12
- package/Voxels/Segments/SubstanceDataGenerator.d.ts +0 -6
- package/Voxels/Segments/SubstanceDataGenerator.js +0 -35
- package/Voxels/Segments/VoxelDataGenerator.d.ts +0 -10
- package/Voxels/Segments/VoxelDataGenerator.js +0 -56
- package/Voxels/Structs/Builder/SubstanceStructBuilder.d.ts +0 -2
- package/Voxels/Structs/Builder/SubstanceStructBuilder.js +0 -42
- package/Voxels/Structs/Builder/VoxelStructBuilder.d.ts +0 -2
- package/Voxels/Structs/Builder/VoxelStructBuilder.js +0 -68
- package/Voxels/Structs/SubstanceStruct.d.ts +0 -17
- package/Voxels/Structs/SubstanceStruct.js +0 -17
- package/Voxels/Structs/VoxelStruct.d.ts +0 -27
- package/Voxels/Structs/VoxelStruct.js +0 -29
- package/World/Section/SectionHeightMap.d.ts +0 -10
- package/World/Section/SectionHeightMap.js +0 -39
- package/World/Section/SectionStruct.d.ts +0 -8
- package/World/Section/SectionStruct.js +0 -29
- package/World/Section/SectionStructProperties.d.ts +0 -10
- package/World/Section/SectionStructProperties.js +0 -11
- package/World/Sector/SectorStruct.d.ts +0 -1
- package/World/Sector/SectorStruct.js +0 -46
- package/World/Sector/SectorStructIds.d.ts +0 -13
- package/World/Sector/SectorStructIds.js +0 -14
- package/World/Structs/WorldDataStructProperties.d.ts +0 -8
- package/World/Structs/WorldDataStructProperties.js +0 -9
- /package/Mesher/{VoxelShaderData.d.ts → Geomtry/VoxelShaderData.d.ts} +0 -0
- /package/Mesher/{VoxelShaderData.js → Geomtry/VoxelShaderData.js} +0 -0
- /package/{Data/Functions → Util/Binary}/Palettes.d.ts +0 -0
- /package/{Data/Functions → Util/Binary}/Palettes.js +0 -0
- /package/{Data/Structs/StructBuilder.types.js → Voxels/Cursor/DataCursor.interface.js} +0 -0
- /package/Voxels/{VoxelLevelReader.d.ts → Cursor/VoxelLevelReader.d.ts} +0 -0
- /package/Voxels/{VoxelLevelReader.js → Cursor/VoxelLevelReader.js} +0 -0
- /package/World/{Storage → Types}/WorldStorage.interface.d.ts +0 -0
- /package/World/{Storage → Types}/WorldStorage.interface.js +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SectionData, SectorData } from "../../index";
|
|
2
2
|
import { ArchivedSectorData } from "../Archive.types";
|
|
3
3
|
type RunData = {
|
|
4
4
|
version?: number;
|
|
5
5
|
loadColumnState?: (data: Record<string, any>, sector: SectorData) => void;
|
|
6
|
-
loadSectionState?: (keys: string[], data: any[], section:
|
|
6
|
+
loadSectionState?: (keys: string[], data: any[], section: SectionData) => void;
|
|
7
7
|
};
|
|
8
|
-
export default function ImportSector(
|
|
8
|
+
export default function ImportSector(archivedSector: ArchivedSectorData, archiveData: RunData): SectorData;
|
|
9
9
|
export {};
|
|
@@ -1,116 +1,169 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Section, Sector } from "../../index";
|
|
3
|
-
import { VoxelStruct } from "../../../Voxels/Structs/VoxelStruct";
|
|
4
|
-
import { VoxelStructIds } from "../../../Voxels/Types/Voxel.types";
|
|
1
|
+
import { Sector } from "../../index";
|
|
5
2
|
import { NumberPalette } from "../../../Util/NumberPalette";
|
|
6
3
|
import { StringPalette } from "../../../Util/StringPalette";
|
|
7
|
-
import { getPaletteArray } from "../../../Data/Functions/Palettes";
|
|
8
4
|
import { SchemaRegister } from "../../../Voxels/State/SchemaRegister";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
ArrayBuffer.isView(section.buffers.id)) {
|
|
15
|
-
section.buffers.id = getPaletteArray(Math.min(section.palettes.id?.length || Infinity, sector.palettes.id?.length || 0), section.buffers.id);
|
|
16
|
-
}
|
|
17
|
-
if (((section.palettes.light && section.palettes.light.length <= 15) ||
|
|
18
|
-
(sector.palettes.light && sector.palettes.light.length <= 15)) &&
|
|
19
|
-
ArrayBuffer.isView(section.buffers.light)) {
|
|
20
|
-
section.buffers.light = getPaletteArray(Math.min(section.palettes.light?.length || Infinity, sector.palettes.light?.length || 0), section.buffers.light);
|
|
21
|
-
}
|
|
22
|
-
if (((section.palettes.state && section.palettes.state.length <= 15) ||
|
|
23
|
-
(sector.palettes.state && sector.palettes.state.length <= 15)) &&
|
|
24
|
-
ArrayBuffer.isView(section.buffers.state)) {
|
|
25
|
-
section.buffers.state = getPaletteArray(Math.min(section.palettes.state?.length || Infinity, sector.palettes.state?.length || 0), section.buffers.state);
|
|
26
|
-
}
|
|
27
|
-
if (((section.palettes.mod && section.palettes.mod.length <= 15) ||
|
|
28
|
-
(sector.palettes.mod && sector.palettes.mod.length <= 15)) &&
|
|
29
|
-
ArrayBuffer.isView(section.buffers.mod)) {
|
|
30
|
-
section.buffers.mod = getPaletteArray(Math.min(section.palettes.mod?.length || Infinity, sector.palettes.mod?.length || 0), section.buffers.mod);
|
|
31
|
-
}
|
|
32
|
-
if (((section.palettes.secondaryState &&
|
|
33
|
-
section.palettes.secondaryState.length <= 15) ||
|
|
34
|
-
(sector.palettes.secondaryState &&
|
|
35
|
-
sector.palettes.secondaryState.length <= 15)) &&
|
|
36
|
-
((section.palettes.secondaryId && section.palettes.secondaryId.length <= 15) ||
|
|
37
|
-
(sector.palettes.secondaryId &&
|
|
38
|
-
sector.palettes.secondaryId.length <= 15)) &&
|
|
39
|
-
ArrayBuffer.isView(section.buffers.secondary)) {
|
|
40
|
-
section.buffers.secondary = getPaletteArray(Math.max(Math.min(section.palettes.secondaryId?.length || Infinity, sector.palettes.secondaryId?.length || 0), Math.min(section.palettes.secondaryState?.length || Infinity, sector.palettes.secondaryState?.length || 0)), section.buffers.secondary);
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
const getImportedColumnData = (sector) => {
|
|
5
|
+
import { VoxelPalettesRegister } from "../../../Voxels/Data/VoxelPalettesRegister";
|
|
6
|
+
import { VoxelTagsRegister } from "../../../Voxels/Data/VoxelTagsRegister";
|
|
7
|
+
import { BinaryBuffer } from "../../../Util/Binary/BinaryBuffer";
|
|
8
|
+
import { lightSegments, lightSemgnetSet } from "./Shared";
|
|
9
|
+
const getImportedSectorData = (sector) => {
|
|
44
10
|
return {
|
|
45
11
|
sector,
|
|
46
12
|
idPalette: new StringPalette(sector.palettes.id),
|
|
47
|
-
secondaryId: sector.palettes.secondaryId
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
lightPalette: sector.palettes.light
|
|
51
|
-
? new NumberPalette(sector.palettes.light)
|
|
52
|
-
: undefined,
|
|
53
|
-
statePalette: sector.palettes.state
|
|
54
|
-
? new NumberPalette(sector.palettes.state)
|
|
55
|
-
: undefined,
|
|
56
|
-
modPalette: sector.palettes.mod
|
|
57
|
-
? new NumberPalette(sector.palettes.mod)
|
|
58
|
-
: undefined,
|
|
59
|
-
secondaryState: sector.palettes.secondaryState
|
|
60
|
-
? new NumberPalette(sector.palettes.secondaryState)
|
|
13
|
+
secondaryId: new StringPalette(sector.palettes.secondaryId),
|
|
14
|
+
levelPalette: sector.palettes.level
|
|
15
|
+
? new NumberPalette(sector.palettes.level)
|
|
61
16
|
: undefined,
|
|
17
|
+
lightPalette: {
|
|
18
|
+
sun: sector.palettes.light.sun
|
|
19
|
+
? new NumberPalette(sector.palettes.light.sun)
|
|
20
|
+
: null,
|
|
21
|
+
red: sector.palettes.light.red
|
|
22
|
+
? new NumberPalette(sector.palettes.light.red)
|
|
23
|
+
: null,
|
|
24
|
+
green: sector.palettes.light.green
|
|
25
|
+
? new NumberPalette(sector.palettes.light.green)
|
|
26
|
+
: null,
|
|
27
|
+
blue: sector.palettes.light.blue
|
|
28
|
+
? new NumberPalette(sector.palettes.light.blue)
|
|
29
|
+
: null,
|
|
30
|
+
},
|
|
31
|
+
statePalette: new NumberPalette(sector.palettes.state),
|
|
32
|
+
modPalette: new NumberPalette(sector.palettes.mod),
|
|
33
|
+
secondaryState: new NumberPalette(sector.palettes.secondaryState),
|
|
62
34
|
};
|
|
63
35
|
};
|
|
64
36
|
const getImportedSectionData = (section) => {
|
|
65
37
|
return {
|
|
66
38
|
section,
|
|
67
|
-
|
|
68
|
-
|
|
39
|
+
buffers: {
|
|
40
|
+
ids: !section.buffers.id
|
|
41
|
+
? new BinaryBuffer({ buffer: 0 })
|
|
42
|
+
: typeof section.buffers.id == "number"
|
|
43
|
+
? new BinaryBuffer({ buffer: section.buffers.id })
|
|
44
|
+
: new BinaryBuffer(section.buffers.id),
|
|
45
|
+
level: !section.buffers.level
|
|
46
|
+
? new BinaryBuffer({ buffer: 0 })
|
|
47
|
+
: typeof section.buffers.level == "number"
|
|
48
|
+
? new BinaryBuffer({ buffer: section.buffers.level })
|
|
49
|
+
: new BinaryBuffer(section.buffers.level),
|
|
50
|
+
light: {
|
|
51
|
+
sun: !section.buffers.light?.sun
|
|
52
|
+
? new BinaryBuffer({ buffer: 0 })
|
|
53
|
+
: typeof section.buffers.light.sun == "number"
|
|
54
|
+
? new BinaryBuffer({ buffer: section.buffers.light.sun })
|
|
55
|
+
: new BinaryBuffer(section.buffers.light.sun),
|
|
56
|
+
red: !section.buffers.light?.red
|
|
57
|
+
? new BinaryBuffer({ buffer: 0 })
|
|
58
|
+
: typeof section.buffers.light.red == "number"
|
|
59
|
+
? new BinaryBuffer({ buffer: section.buffers.light.red })
|
|
60
|
+
: new BinaryBuffer(section.buffers.light.red),
|
|
61
|
+
green: !section.buffers.light?.green
|
|
62
|
+
? new BinaryBuffer({ buffer: 0 })
|
|
63
|
+
: typeof section.buffers.light.green == "number"
|
|
64
|
+
? new BinaryBuffer({ buffer: section.buffers.light.green })
|
|
65
|
+
: new BinaryBuffer(section.buffers.light.green),
|
|
66
|
+
blue: !section.buffers.light?.blue
|
|
67
|
+
? new BinaryBuffer({ buffer: 0 })
|
|
68
|
+
: typeof section.buffers.light.blue == "number"
|
|
69
|
+
? new BinaryBuffer({ buffer: section.buffers.light.blue })
|
|
70
|
+
: new BinaryBuffer(section.buffers.light.blue),
|
|
71
|
+
},
|
|
72
|
+
state: !section.buffers.state
|
|
73
|
+
? new BinaryBuffer({ buffer: 0 })
|
|
74
|
+
: typeof section.buffers.state == "number"
|
|
75
|
+
? new BinaryBuffer({ buffer: section.buffers.state })
|
|
76
|
+
: new BinaryBuffer(section.buffers.state),
|
|
77
|
+
mod: !section.buffers.mod
|
|
78
|
+
? new BinaryBuffer({ buffer: 0 })
|
|
79
|
+
: typeof section.buffers.mod == "number"
|
|
80
|
+
? new BinaryBuffer({ buffer: section.buffers.mod })
|
|
81
|
+
: new BinaryBuffer(section.buffers.mod),
|
|
82
|
+
secondary: !section.buffers.secondary
|
|
83
|
+
? new BinaryBuffer({ buffer: 0 })
|
|
84
|
+
: typeof section.buffers.secondary == "number"
|
|
85
|
+
? new BinaryBuffer({ buffer: section.buffers.secondary })
|
|
86
|
+
: new BinaryBuffer(section.buffers.secondary),
|
|
87
|
+
},
|
|
88
|
+
idPalette: section.palettes?.id
|
|
89
|
+
? new NumberPalette(section.palettes?.id)
|
|
69
90
|
: undefined,
|
|
70
|
-
lightPalette:
|
|
71
|
-
|
|
91
|
+
lightPalette: {
|
|
92
|
+
sun: section.palettes?.light?.sun
|
|
93
|
+
? new NumberPalette(section.palettes?.light?.sun)
|
|
94
|
+
: null,
|
|
95
|
+
red: section.palettes?.light?.red
|
|
96
|
+
? new NumberPalette(section.palettes?.light?.red)
|
|
97
|
+
: null,
|
|
98
|
+
green: section.palettes?.light?.green
|
|
99
|
+
? new NumberPalette(section.palettes?.light?.green)
|
|
100
|
+
: null,
|
|
101
|
+
blue: section.palettes?.light?.blue
|
|
102
|
+
? new NumberPalette(section.palettes?.light?.blue)
|
|
103
|
+
: null,
|
|
104
|
+
},
|
|
105
|
+
levelPalette: section.palettes?.level
|
|
106
|
+
? new NumberPalette(section.palettes?.level)
|
|
72
107
|
: undefined,
|
|
73
|
-
statePalette: section.palettes
|
|
74
|
-
? new NumberPalette(section.palettes
|
|
108
|
+
statePalette: section.palettes?.state
|
|
109
|
+
? new NumberPalette(section.palettes?.state)
|
|
75
110
|
: undefined,
|
|
76
|
-
modPalette: section.palettes
|
|
77
|
-
? new NumberPalette(section.palettes
|
|
111
|
+
modPalette: section.palettes?.mod
|
|
112
|
+
? new NumberPalette(section.palettes?.mod)
|
|
78
113
|
: undefined,
|
|
79
|
-
secondaryState: section.palettes
|
|
80
|
-
? new NumberPalette(section.palettes
|
|
114
|
+
secondaryState: section.palettes?.secondaryState
|
|
115
|
+
? new NumberPalette(section.palettes?.secondaryState)
|
|
81
116
|
: undefined,
|
|
82
|
-
secondaryId: section.palettes
|
|
83
|
-
? new NumberPalette(section.palettes
|
|
117
|
+
secondaryId: section.palettes?.secondaryId
|
|
118
|
+
? new NumberPalette(section.palettes?.secondaryId)
|
|
84
119
|
: undefined,
|
|
85
120
|
};
|
|
86
121
|
};
|
|
87
|
-
const getId = (value,
|
|
88
|
-
if (importedSection.
|
|
89
|
-
return value;
|
|
90
|
-
if (typeof importedSection.section.buffers.id == "number") {
|
|
91
|
-
return VoxelPalette.ids.getNumberId(importedColumn.sector.palettes.id[importedSection.section.buffers.id]);
|
|
122
|
+
const getId = (value, importedSector, importedSection) => {
|
|
123
|
+
if (importedSection.buffers.ids.type == "value") {
|
|
124
|
+
return VoxelPalettesRegister.voxels.getNumberId(importedSector.idPalette.getStringId(value));
|
|
92
125
|
}
|
|
93
126
|
if (importedSection.idPalette) {
|
|
94
|
-
return
|
|
127
|
+
return VoxelPalettesRegister.voxels.getNumberId(importedSector.idPalette.getStringId(importedSection.idPalette.getValue(value)));
|
|
95
128
|
}
|
|
96
|
-
return
|
|
129
|
+
return VoxelPalettesRegister.voxels.getNumberId(importedSector.idPalette.getStringId(value));
|
|
97
130
|
};
|
|
98
|
-
const getLight = (
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
131
|
+
const getLight = (index, importedSector, importedSection) => {
|
|
132
|
+
let finalLight = 0;
|
|
133
|
+
for (let l = 0; l < lightSegments.length; l++) {
|
|
134
|
+
const segment = lightSegments[l];
|
|
135
|
+
let value = 0;
|
|
136
|
+
if (importedSection.buffers.light[segment].type == "value") {
|
|
137
|
+
value = importedSection.buffers.light[segment].getValue(index);
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
if (importedSection.buffers.light[segment].type == "4-bit") {
|
|
141
|
+
value = importedSection.buffers.light[segment].getValue(index);
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
if (importedSection.lightPalette[segment]) {
|
|
145
|
+
value = importedSection.lightPalette[segment].getValue(importedSection.buffers.light[segment].getValue(index));
|
|
146
|
+
}
|
|
147
|
+
else if (importedSector.lightPalette[segment]) {
|
|
148
|
+
value = importedSector.lightPalette[segment].getValue(importedSection.buffers.light[segment].getValue(index));
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
finalLight = lightSemgnetSet[segment](value, finalLight);
|
|
103
153
|
}
|
|
104
|
-
|
|
105
|
-
|
|
154
|
+
return finalLight;
|
|
155
|
+
};
|
|
156
|
+
const getLevel = (value, importedSector, importedSection) => {
|
|
157
|
+
if (importedSection.levelPalette) {
|
|
158
|
+
return importedSection.levelPalette.getValue(value);
|
|
106
159
|
}
|
|
107
|
-
if (
|
|
108
|
-
return
|
|
160
|
+
if (importedSector.levelPalette) {
|
|
161
|
+
return importedSector.levelPalette.getValue(value);
|
|
109
162
|
}
|
|
110
163
|
return value;
|
|
111
164
|
};
|
|
112
|
-
const getState = (voxelId, value, processedState,
|
|
113
|
-
const voxelStringId =
|
|
165
|
+
const getState = (voxelId, value, processedState, importedSector, importedSection) => {
|
|
166
|
+
const voxelStringId = VoxelPalettesRegister.voxels.getStringId(voxelId);
|
|
114
167
|
if (!SchemaRegister.hasVoxelSchema(voxelStringId))
|
|
115
168
|
return value;
|
|
116
169
|
let stateId = -1;
|
|
@@ -121,17 +174,17 @@ const getState = (voxelId, value, processedState, importedColumn, importedSectio
|
|
|
121
174
|
if (importedSection.statePalette) {
|
|
122
175
|
stateId = importedSection.statePalette.getValue(value);
|
|
123
176
|
}
|
|
124
|
-
else if (
|
|
177
|
+
else if (importedSector.statePalette) {
|
|
125
178
|
stateId = value;
|
|
126
179
|
}
|
|
127
180
|
if (processedState[stateId] !== undefined)
|
|
128
181
|
return processedState[stateId];
|
|
129
|
-
value = SchemaRegister.getVoxelSchemas(voxelStringId).state.fromStateObject(
|
|
182
|
+
value = SchemaRegister.getVoxelSchemas(voxelStringId).state.fromStateObject(importedSector.sector.palettes.stateMap[stateId]);
|
|
130
183
|
processedState[stateId] = value;
|
|
131
184
|
return value;
|
|
132
185
|
};
|
|
133
|
-
const getMod = (voxelId, value, processedMod,
|
|
134
|
-
const voxelStringId =
|
|
186
|
+
const getMod = (voxelId, value, processedMod, importedSector, importedSection) => {
|
|
187
|
+
const voxelStringId = VoxelPalettesRegister.voxels.getStringId(voxelId);
|
|
135
188
|
if (!SchemaRegister.hasVoxelSchema(voxelStringId))
|
|
136
189
|
return value;
|
|
137
190
|
let modId = -1;
|
|
@@ -142,93 +195,94 @@ const getMod = (voxelId, value, processedMod, importedColumn, importedSection) =
|
|
|
142
195
|
if (importedSection.modPalette) {
|
|
143
196
|
modId = importedSection.modPalette.getValue(value);
|
|
144
197
|
}
|
|
145
|
-
else if (
|
|
198
|
+
else if (importedSector.modPalette) {
|
|
146
199
|
modId = value;
|
|
147
200
|
}
|
|
148
201
|
if (processedMod[modId] !== undefined)
|
|
149
202
|
return processedMod[modId];
|
|
150
|
-
value = SchemaRegister.getVoxelSchemas(voxelStringId).mod.fromStateObject(
|
|
203
|
+
value = SchemaRegister.getVoxelSchemas(voxelStringId).mod.fromStateObject(importedSector.sector.palettes.modMap[modId]);
|
|
151
204
|
processedMod[modId] = value;
|
|
152
205
|
return value;
|
|
153
206
|
};
|
|
154
|
-
const getSecondary = (voxelId, value,
|
|
155
|
-
|
|
156
|
-
if (VoxelStruct.instance[VoxelStructIds.canHaveSecondary] == 1) {
|
|
157
|
-
if (typeof importedSection.section.buffers.secondary == "number") {
|
|
158
|
-
return VoxelPalette.ids.getNumberId(importedColumn.sector.palettes.secondaryId[importedSection.section.buffers.secondary]);
|
|
159
|
-
}
|
|
207
|
+
const getSecondary = (voxelId, value, importedSector, importedSection) => {
|
|
208
|
+
if (VoxelTagsRegister.VoxelTags[voxelId]["dve_can_have_secondary"]) {
|
|
160
209
|
if (importedSection.secondaryId) {
|
|
161
|
-
return
|
|
210
|
+
return VoxelPalettesRegister.voxels.getNumberId(importedSector.secondaryId.getStringId(importedSection.secondaryId.getValue(value)));
|
|
162
211
|
}
|
|
163
|
-
return
|
|
212
|
+
return VoxelPalettesRegister.voxels.getNumberId(importedSector.sector.palettes.secondaryId[value]);
|
|
164
213
|
}
|
|
165
214
|
if (typeof importedSection.section.buffers.secondary == "number") {
|
|
166
215
|
return value;
|
|
167
216
|
}
|
|
168
|
-
if (importedSection.secondaryState &&
|
|
169
|
-
return
|
|
217
|
+
if (importedSection.secondaryState && importedSector.secondaryState) {
|
|
218
|
+
return importedSector.secondaryState.getValue(importedSection.secondaryState.getValue(value));
|
|
170
219
|
}
|
|
171
|
-
if (
|
|
172
|
-
return
|
|
220
|
+
if (importedSector.secondaryState) {
|
|
221
|
+
return importedSector.secondaryState.getId(value);
|
|
173
222
|
}
|
|
174
223
|
return value;
|
|
175
224
|
};
|
|
176
|
-
export default function ImportSector(
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
if (!archiveData.loadColumnState) {
|
|
186
|
-
sectorStructInstance.setData(newSector.sectorState);
|
|
187
|
-
sectorStructInstance.deserialize(sector.sectorState);
|
|
188
|
-
}
|
|
189
|
-
else {
|
|
190
|
-
archiveData.loadColumnState(sector.sectorState, newSector);
|
|
191
|
-
}
|
|
192
|
-
const importedSector = getImportedColumnData(sector);
|
|
225
|
+
export default function ImportSector(archivedSector, archiveData) {
|
|
226
|
+
const sector = new Sector(Sector.CreateNew(), [
|
|
227
|
+
archivedSector.location[1],
|
|
228
|
+
archivedSector.location[2],
|
|
229
|
+
archivedSector.location[3],
|
|
230
|
+
]);
|
|
231
|
+
sector.loadFlags(archivedSector.flags);
|
|
232
|
+
sector.loadTimestamps(archivedSector.timestamps);
|
|
233
|
+
const importedSector = getImportedSectorData(archivedSector);
|
|
193
234
|
const processedState = {};
|
|
194
235
|
const processedMod = {};
|
|
195
|
-
for (let sectionIndex = 0; sectionIndex <
|
|
236
|
+
for (let sectionIndex = 0; sectionIndex < archivedSector.sections.length; sectionIndex++) {
|
|
237
|
+
const archivedSectionValue = archivedSector.sections[sectionIndex];
|
|
238
|
+
const archivedSection = typeof archivedSectionValue == "string"
|
|
239
|
+
? archivedSector.duplicates?.sections?.[archivedSectionValue]
|
|
240
|
+
: archivedSectionValue;
|
|
241
|
+
const importedSection = getImportedSectionData(archivedSection);
|
|
196
242
|
const section = sector.sections[sectionIndex];
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
243
|
+
archivedSection.flags && section.loadFlags(archivedSection.flags);
|
|
244
|
+
if (!ArrayBuffer.isView(archivedSection.buffers.buried)) {
|
|
245
|
+
for (let i = 0; i < section.buried.length; i++) {
|
|
246
|
+
section.buried[i] = archivedSection.buffers.buried || 0;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
for (let i = 0; i < section.buried.length; i++) {
|
|
251
|
+
section.buried[i] = archivedSection.buffers.buried[i];
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
if (!ArrayBuffer.isView(archivedSection.buffers.voxelMap)) {
|
|
255
|
+
for (let i = 0; i < section.voxelMap.length; i++) {
|
|
256
|
+
section.voxelMap[i] = archivedSection.buffers.voxelMap || 0;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
for (let i = 0; i < section.voxelMap.length; i++) {
|
|
261
|
+
section.voxelMap[i] = archivedSection.buffers.voxelMap[i];
|
|
262
|
+
}
|
|
202
263
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
264
|
+
if (!ArrayBuffer.isView(archivedSection.buffers.dirtyMap)) {
|
|
265
|
+
for (let i = 0; i < section.dirtyMap.length; i++) {
|
|
266
|
+
section.dirtyMap[i] = archivedSection.buffers.dirtyMap || 0;
|
|
267
|
+
}
|
|
207
268
|
}
|
|
208
269
|
else {
|
|
209
|
-
|
|
270
|
+
for (let i = 0; i < section.dirtyMap.length; i++) {
|
|
271
|
+
section.dirtyMap[i] = archivedSection.buffers.dirtyMap[i];
|
|
272
|
+
}
|
|
210
273
|
}
|
|
211
|
-
for (let i = 0; i <
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
: section.buffers.secondary[i], importedSector, importedSection);
|
|
221
|
-
VoxelStruct.setVoxel(newSection.ids[i]);
|
|
222
|
-
let secondary = VoxelStruct.instance[VoxelStructIds.canHaveSecondary] &&
|
|
223
|
-
newSection.secondary[i] > 0;
|
|
224
|
-
newSection.state[i] = getState(secondary ? newSection.secondary[i] : newSection.ids[i], typeof section.buffers.state == "number"
|
|
225
|
-
? section.buffers.state
|
|
226
|
-
: section.buffers.state[i], processedState, importedSector, importedSection);
|
|
227
|
-
newSection.mod[i] = getMod(secondary ? newSection.secondary[i] : newSection.ids[i], typeof section.buffers.mod == "number"
|
|
228
|
-
? section.buffers.mod
|
|
229
|
-
: section.buffers.mod[i], processedMod, importedSector, importedSection);
|
|
274
|
+
for (let i = 0; i < section.ids.length; i++) {
|
|
275
|
+
section.ids[i] = getId(importedSection.buffers.ids.getValue(i), importedSector, importedSection);
|
|
276
|
+
section.level[i] = getLevel(importedSection.buffers.level.getValue(i), importedSector, importedSection);
|
|
277
|
+
section.light[i] = getLight(i, importedSector, importedSection);
|
|
278
|
+
section.secondary[i] = getSecondary(section.ids[i], importedSection.buffers.secondary.getValue(i), importedSector, importedSection);
|
|
279
|
+
let secondary = VoxelTagsRegister.VoxelTags[section.ids[i]]["dve_can_have_secondary"] &&
|
|
280
|
+
section.secondary[i] > 0;
|
|
281
|
+
section.state[i] = getState(secondary ? section.secondary[i] : section.ids[i], importedSection.buffers.state.getValue(i), processedState, importedSector, importedSection);
|
|
282
|
+
section.mod[i] = getMod(secondary ? section.secondary[i] : section.ids[i], importedSection.buffers.mod.getValue(i), processedMod, importedSector, importedSection);
|
|
230
283
|
}
|
|
231
|
-
|
|
284
|
+
sector.sections[sectionIndex] = section;
|
|
232
285
|
}
|
|
233
|
-
|
|
286
|
+
sector.setBitFlag(Sector.FlagIds.isStored, true);
|
|
287
|
+
return sector;
|
|
234
288
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ArchivedLightSegments, ArchivedSectionData } from "../Archive.types";
|
|
2
|
+
export declare const lightSegments: ArchivedLightSegments[];
|
|
3
|
+
export declare const lightSemgnetGet: Record<ArchivedLightSegments, (value: number) => number>;
|
|
4
|
+
export declare const lightSemgnetSet: Record<ArchivedLightSegments, (value: number, source: number) => number>;
|
|
5
|
+
export declare function uint16To4CharString(value: number): string;
|
|
6
|
+
export declare function compareSection(section1: ArchivedSectionData, section2: ArchivedSectionData): boolean;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { VoxelLightData } from "../../../Voxels/Cursor/VoxelLightData";
|
|
2
|
+
const lightData = new VoxelLightData();
|
|
3
|
+
export const lightSegments = [
|
|
4
|
+
"sun",
|
|
5
|
+
"red",
|
|
6
|
+
"green",
|
|
7
|
+
"blue",
|
|
8
|
+
];
|
|
9
|
+
export const lightSemgnetGet = {
|
|
10
|
+
sun: (value) => lightData.getS(value),
|
|
11
|
+
red: (value) => lightData.getR(value),
|
|
12
|
+
green: (value) => lightData.getG(value),
|
|
13
|
+
blue: (value) => lightData.getB(value),
|
|
14
|
+
};
|
|
15
|
+
export const lightSemgnetSet = {
|
|
16
|
+
sun: (value, source) => lightData.setS(value, source),
|
|
17
|
+
red: (value, source) => lightData.setR(value, source),
|
|
18
|
+
green: (value, source) => lightData.setG(value, source),
|
|
19
|
+
blue: (value, source) => lightData.setB(value, source),
|
|
20
|
+
};
|
|
21
|
+
const charset = "0123456789ABCDEF";
|
|
22
|
+
export function uint16To4CharString(value) {
|
|
23
|
+
if (value < 0 || value > 0xffff) {
|
|
24
|
+
throw new RangeError("Value must be a 16-bit unsigned integer.");
|
|
25
|
+
}
|
|
26
|
+
const chars = [];
|
|
27
|
+
for (let i = 0; i < 4; i++) {
|
|
28
|
+
const charCode = (value >> (i * 4)) & 0x0f;
|
|
29
|
+
chars.unshift(charset[charCode]);
|
|
30
|
+
}
|
|
31
|
+
const result = chars.join("").replace(/^0+(?!$)/, "");
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
function traverseSection(source, target) {
|
|
35
|
+
for (const key in source) {
|
|
36
|
+
if (!(key in target))
|
|
37
|
+
return false;
|
|
38
|
+
const sourceValue = source[key];
|
|
39
|
+
const targetValue = target[key];
|
|
40
|
+
if (!ArrayBuffer.isView(sourceValue) &&
|
|
41
|
+
typeof sourceValue === "object" &&
|
|
42
|
+
sourceValue !== null &&
|
|
43
|
+
!ArrayBuffer.isView(targetValue) &&
|
|
44
|
+
typeof targetValue == "object" &&
|
|
45
|
+
targetValue !== null) {
|
|
46
|
+
if (!traverseSection(sourceValue, targetValue))
|
|
47
|
+
return false;
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (typeof sourceValue === "number" ||
|
|
51
|
+
typeof sourceValue === "string" ||
|
|
52
|
+
typeof targetValue === "number" ||
|
|
53
|
+
typeof targetValue === "string") {
|
|
54
|
+
if (sourceValue !== targetValue)
|
|
55
|
+
return false;
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (sourceValue instanceof Uint8Array ||
|
|
59
|
+
sourceValue instanceof Uint16Array) {
|
|
60
|
+
if (!(targetValue instanceof sourceValue.constructor))
|
|
61
|
+
return false;
|
|
62
|
+
if (sourceValue.length !== targetValue.length)
|
|
63
|
+
return false;
|
|
64
|
+
let target = targetValue;
|
|
65
|
+
for (let i = 0; i < target.length; i++) {
|
|
66
|
+
if (sourceValue[i] != target[i])
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
export function compareSection(section1, section2) {
|
|
74
|
+
return traverseSection(section1, section2);
|
|
75
|
+
}
|
|
@@ -11,27 +11,37 @@ function runArchiveSector(location) {
|
|
|
11
11
|
location: location,
|
|
12
12
|
});
|
|
13
13
|
const transfers = [];
|
|
14
|
-
if (archived.palettes.light)
|
|
15
|
-
transfers.push(archived.palettes.light.buffer);
|
|
14
|
+
// if (archived.palettes.light) transfers.push(archived.palettes.light.buffer);
|
|
16
15
|
if (archived.palettes.state)
|
|
17
16
|
transfers.push(archived.palettes.state.buffer);
|
|
18
17
|
if (archived.palettes.secondaryState)
|
|
19
18
|
transfers.push(archived.palettes.secondaryState.buffer);
|
|
20
19
|
for (const section of archived.sections) {
|
|
21
|
-
if (typeof section
|
|
20
|
+
if (typeof section == "string")
|
|
21
|
+
continue;
|
|
22
|
+
if (ArrayBuffer.isView(section.buffers.id?.buffer))
|
|
22
23
|
transfers.push(section.buffers.id.buffer);
|
|
23
|
-
if (
|
|
24
|
-
transfers.push(section.buffers.light.buffer);
|
|
25
|
-
if (typeof section.buffers.state != "number")
|
|
24
|
+
if (ArrayBuffer.isView(section.buffers.state?.buffer))
|
|
26
25
|
transfers.push(section.buffers.state.buffer);
|
|
27
|
-
if (
|
|
28
|
-
transfers.push(section.buffers.secondary.buffer);
|
|
29
|
-
if (typeof section.buffers.mod != "number")
|
|
26
|
+
if (ArrayBuffer.isView(section.buffers.mod?.buffer))
|
|
30
27
|
transfers.push(section.buffers.mod.buffer);
|
|
28
|
+
if (ArrayBuffer.isView(section.buffers.state?.buffer))
|
|
29
|
+
transfers.push(section.buffers.state.buffer);
|
|
30
|
+
if (ArrayBuffer.isView(section.buffers.light?.sun?.buffer))
|
|
31
|
+
transfers.push((section.buffers.light?.sun).buffer);
|
|
32
|
+
if (ArrayBuffer.isView(section.buffers.light?.red?.buffer))
|
|
33
|
+
transfers.push((section.buffers.light?.red).buffer);
|
|
34
|
+
if (ArrayBuffer.isView(section.buffers.light?.green?.buffer))
|
|
35
|
+
transfers.push((section.buffers.light?.green).buffer);
|
|
36
|
+
if (ArrayBuffer.isView(section.buffers.light?.blue?.buffer))
|
|
37
|
+
transfers.push((section.buffers.light?.blue).buffer);
|
|
38
|
+
if (ArrayBuffer.isView(section.buffers.secondary?.buffer))
|
|
39
|
+
transfers.push(section.buffers.secondary.buffer);
|
|
40
|
+
if (!section.palettes)
|
|
41
|
+
continue;
|
|
31
42
|
if (section.palettes.id)
|
|
32
43
|
transfers.push(section.palettes.id.buffer);
|
|
33
|
-
if (section.palettes.light)
|
|
34
|
-
transfers.push(section.palettes.light.buffer);
|
|
44
|
+
// if (section.palettes.light) transfers.push(section.palettes.light.buffer);
|
|
35
45
|
if (section.palettes.state)
|
|
36
46
|
transfers.push(section.palettes.state.buffer);
|
|
37
47
|
if (section.palettes.mod)
|
|
@@ -49,8 +59,15 @@ export default function InitTasks(props) {
|
|
|
49
59
|
});
|
|
50
60
|
Threads.registerTask("archive-sector-binary", async (location) => {
|
|
51
61
|
const [archived] = runArchiveSector(location);
|
|
52
|
-
|
|
53
|
-
|
|
62
|
+
try {
|
|
63
|
+
const compressed = await compressBinaryObject(archived);
|
|
64
|
+
return [compressed, [compressed]];
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
console.log(archived);
|
|
68
|
+
console.error(error);
|
|
69
|
+
}
|
|
70
|
+
return [null, []];
|
|
54
71
|
});
|
|
55
72
|
Threads.registerTask("import-sector", async (archived) => {
|
|
56
73
|
const importedSector = ImportSector(archived, {});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { WorldVoxelCursor } from "./WorldVoxelCursor";
|
|
2
2
|
import { Vector3Like } from "@amodx/math";
|
|
3
|
-
import { DataCursorInterface } from "../../
|
|
3
|
+
import { DataCursorInterface } from "../../Voxels/Cursor/DataCursor.interface";
|
|
4
4
|
import { WorldSectionCursorInterface } from "./WorldSectionCursor.interface";
|
|
5
5
|
import type { Section } from "../Section/index";
|
|
6
|
-
export declare class SectionCursor
|
|
6
|
+
export declare class SectionCursor implements DataCursorInterface, WorldSectionCursorInterface {
|
|
7
7
|
_section: Section | null;
|
|
8
8
|
private voxel;
|
|
9
9
|
_voxelIndex: number;
|
|
@@ -12,5 +12,6 @@ export declare class SectionCursor extends DataCursorInterface implements WorldS
|
|
|
12
12
|
inBounds(x: number, y: number, z: number): boolean;
|
|
13
13
|
setSection(section: Section): boolean;
|
|
14
14
|
setSection(dimension: string, x: number, y: number, z: number): boolean;
|
|
15
|
+
getVoxelAtIndex(index: number): WorldVoxelCursor;
|
|
15
16
|
getVoxel(x: number, y: number, z: number): WorldVoxelCursor | null;
|
|
16
17
|
}
|