@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,207 @@
|
|
|
1
|
+
import { BinaryBuffer, BinaryBufferTypes, } from "../../../Util/Binary/BinaryBuffer";
|
|
2
|
+
import { getLightBuffer, lightSegments } from "./Shared";
|
|
3
|
+
export function CreateArchivedSection(archiveSection, sectorPalettes) {
|
|
4
|
+
const palettes = {};
|
|
5
|
+
if (archiveSection.ids.remapped)
|
|
6
|
+
palettes.id = Uint16Array.from(archiveSection.palettes.ids._palette);
|
|
7
|
+
if (archiveSection.level.remapped)
|
|
8
|
+
palettes.level = Uint8Array.from(archiveSection.palettes.level._palette);
|
|
9
|
+
if (archiveSection.light.sun.remapped) {
|
|
10
|
+
palettes.light ??= {};
|
|
11
|
+
palettes.light.sun = Uint8Array.from(archiveSection.palettes.light.sun._palette);
|
|
12
|
+
}
|
|
13
|
+
if (archiveSection.light.red.remapped) {
|
|
14
|
+
palettes.light ??= {};
|
|
15
|
+
palettes.light.red = Uint8Array.from(archiveSection.palettes.light.red._palette);
|
|
16
|
+
}
|
|
17
|
+
if (archiveSection.light.green.remapped) {
|
|
18
|
+
palettes.light ??= {};
|
|
19
|
+
palettes.light.green = Uint8Array.from(archiveSection.palettes.light.green._palette);
|
|
20
|
+
}
|
|
21
|
+
if (archiveSection.light.blue.remapped) {
|
|
22
|
+
palettes.light ??= {};
|
|
23
|
+
palettes.light.blue = Uint8Array.from(archiveSection.palettes.light.blue._palette);
|
|
24
|
+
}
|
|
25
|
+
if (archiveSection.state.remapped) {
|
|
26
|
+
for (const i in archiveSection.palettes.state) {
|
|
27
|
+
palettes.state ??= [];
|
|
28
|
+
palettes.state[i] = Uint16Array.from(archiveSection.palettes.state[i]._palette);
|
|
29
|
+
}
|
|
30
|
+
for (const i in archiveSection.palettes.secondaryState) {
|
|
31
|
+
palettes.secondaryState ??= [];
|
|
32
|
+
palettes.secondaryState[i] = Uint16Array.from(archiveSection.palettes.secondaryState[i]._palette);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (archiveSection.mod.remapped) {
|
|
36
|
+
for (const i in archiveSection.palettes.mod) {
|
|
37
|
+
palettes.mod ??= [];
|
|
38
|
+
palettes.mod[i] = Uint16Array.from(archiveSection.palettes.mod[i]._palette);
|
|
39
|
+
}
|
|
40
|
+
for (const i in archiveSection.palettes.secondaryMod) {
|
|
41
|
+
palettes.secondaryMod ??= [];
|
|
42
|
+
palettes.secondaryMod[i] = Uint16Array.from(archiveSection.palettes.secondaryMod[i]._palette);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (archiveSection.secondary.remapped) {
|
|
46
|
+
palettes.secondaryId = Uint16Array.from(archiveSection.palettes.secondaryId._palette);
|
|
47
|
+
palettes.secondaryValue = Uint16Array.from(archiveSection.palettes.secondaryValue._palette);
|
|
48
|
+
}
|
|
49
|
+
const buffers = {};
|
|
50
|
+
//id
|
|
51
|
+
if (archiveSection.ids.allTheSame) {
|
|
52
|
+
if (archiveSection.ids.buffer[0] !== 0) {
|
|
53
|
+
buffers.id = archiveSection.ids.buffer[0];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
else if (archiveSection.ids.isPaletted) {
|
|
57
|
+
const type = BinaryBuffer.DetermineSubByteArray(archiveSection.ids.remapped
|
|
58
|
+
? archiveSection.palettes.ids.size
|
|
59
|
+
: sectorPalettes.ids.size);
|
|
60
|
+
buffers.id = BinaryBuffer.Create({
|
|
61
|
+
buffer: BinaryBuffer.Convert(archiveSection.ids.buffer, BinaryBufferTypes.ShortArray, type).buffer,
|
|
62
|
+
type,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
buffers.id = BinaryBuffer.Create({
|
|
67
|
+
buffer: archiveSection.ids.buffer.buffer,
|
|
68
|
+
type: BinaryBufferTypes.ShortArray,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
//level
|
|
72
|
+
if (archiveSection.level.allTheSame) {
|
|
73
|
+
if (archiveSection.level.buffer[0] !== 0) {
|
|
74
|
+
buffers.level = archiveSection.level.buffer[0];
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
else if (archiveSection.level.isPaletted) {
|
|
78
|
+
const type = BinaryBuffer.DetermineSubByteArray(archiveSection.level.remapped
|
|
79
|
+
? archiveSection.palettes.level.size
|
|
80
|
+
: sectorPalettes.level.size);
|
|
81
|
+
buffers.level = BinaryBuffer.Create({
|
|
82
|
+
buffer: BinaryBuffer.Convert(archiveSection.level.buffer, BinaryBufferTypes.ByteArray, type).buffer,
|
|
83
|
+
type,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
buffers.level = BinaryBuffer.Create({
|
|
88
|
+
buffer: archiveSection.original.level.slice().buffer,
|
|
89
|
+
type: BinaryBufferTypes.ByteArray,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
for (const semgnet of lightSegments) {
|
|
93
|
+
if (archiveSection.light[semgnet].allTheSame) {
|
|
94
|
+
if (archiveSection.light[semgnet].value !== 0) {
|
|
95
|
+
buffers.light ??= {};
|
|
96
|
+
buffers.light[semgnet] = archiveSection.light[semgnet].value;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
else if (archiveSection.light[semgnet].isPaletted) {
|
|
100
|
+
const type = BinaryBuffer.DetermineSubByteArray(archiveSection.light[semgnet].remapped
|
|
101
|
+
? archiveSection.palettes.light[semgnet].size
|
|
102
|
+
: sectorPalettes.light[semgnet].size);
|
|
103
|
+
buffers.light ??= {};
|
|
104
|
+
buffers.light[semgnet] = BinaryBuffer.Create({
|
|
105
|
+
buffer: BinaryBuffer.Convert(archiveSection.light[semgnet].buffer, BinaryBufferTypes.ByteArray, type).buffer,
|
|
106
|
+
type,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
buffers.light ??= {};
|
|
111
|
+
buffers.light[semgnet] = BinaryBuffer.Create({
|
|
112
|
+
buffer: getLightBuffer(semgnet, archiveSection.original.light).buffer,
|
|
113
|
+
type: BinaryBufferTypes.NibbleArray,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (archiveSection.state.allTheSame) {
|
|
118
|
+
if (archiveSection.state.buffer[0] !== 0) {
|
|
119
|
+
buffers.state = archiveSection.state.buffer[0];
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
else if (archiveSection.state.isPaletted) {
|
|
123
|
+
const type = BinaryBuffer.DetermineSubByteArray(archiveSection.state.remapped
|
|
124
|
+
? archiveSection.palettes.maxStatePaletteSize
|
|
125
|
+
: sectorPalettes.maxStatePaletteSize);
|
|
126
|
+
buffers.state = BinaryBuffer.Create({
|
|
127
|
+
buffer: BinaryBuffer.Convert(archiveSection.state.buffer, BinaryBufferTypes.ShortArray, type).buffer,
|
|
128
|
+
type,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
buffers.state = BinaryBuffer.Create({
|
|
133
|
+
buffer: archiveSection.state.buffer.buffer,
|
|
134
|
+
type: BinaryBufferTypes.ShortArray,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
if (archiveSection.mod.allTheSame) {
|
|
138
|
+
if (archiveSection.mod.buffer[0] !== 0) {
|
|
139
|
+
buffers.mod = archiveSection.mod.buffer[0];
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
else if (archiveSection.mod.isPaletted) {
|
|
143
|
+
const type = BinaryBuffer.DetermineSubByteArray(archiveSection.mod.remapped
|
|
144
|
+
? archiveSection.palettes.maxModPaletteSize
|
|
145
|
+
: sectorPalettes.maxModPaletteSize);
|
|
146
|
+
buffers.mod = BinaryBuffer.Create({
|
|
147
|
+
buffer: BinaryBuffer.Convert(archiveSection.mod.buffer, BinaryBufferTypes.ShortArray, type).buffer,
|
|
148
|
+
type,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
buffers.mod = BinaryBuffer.Create({
|
|
153
|
+
buffer: archiveSection.mod.buffer.buffer,
|
|
154
|
+
type: BinaryBufferTypes.ShortArray,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
if (archiveSection.secondary.allTheSame) {
|
|
158
|
+
if (archiveSection.secondary.buffer[0] !== 0) {
|
|
159
|
+
buffers.secondary = archiveSection.secondary.buffer[0];
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
else if (archiveSection.secondary.isPaletted) {
|
|
163
|
+
const type = BinaryBuffer.DetermineSubByteArray(archiveSection.secondary.remapped
|
|
164
|
+
? Math.max(archiveSection.palettes.secondaryValue.size, archiveSection.palettes.secondaryId.size)
|
|
165
|
+
: Math.max(sectorPalettes.secondaryValue.size, sectorPalettes.secondaryId.size));
|
|
166
|
+
buffers.secondary = BinaryBuffer.Create({
|
|
167
|
+
buffer: BinaryBuffer.Convert(archiveSection.secondary.buffer, BinaryBufferTypes.ShortArray, type).buffer,
|
|
168
|
+
type,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
buffers.secondary = BinaryBuffer.Create({
|
|
173
|
+
buffer: archiveSection.secondary.buffer.buffer,
|
|
174
|
+
type: BinaryBufferTypes.ShortArray,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
if (archiveSection.isBuriedAllTheSame) {
|
|
178
|
+
if (archiveSection.buriedValue !== 0) {
|
|
179
|
+
buffers.buried = archiveSection.buriedValue;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
buffers.buried = archiveSection.original.buried.slice();
|
|
184
|
+
}
|
|
185
|
+
if (archiveSection.isVoxelMapAllTheSame) {
|
|
186
|
+
if (archiveSection.voxelMapValue !== 0) {
|
|
187
|
+
buffers.voxelMap = archiveSection.voxelMapValue;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
buffers.voxelMap = archiveSection.original.voxelMap.slice();
|
|
192
|
+
}
|
|
193
|
+
if (archiveSection.isDirtyMapAllTheSame) {
|
|
194
|
+
if (archiveSection.dirtyMapValue !== 0) {
|
|
195
|
+
buffers.dirtyMap = archiveSection.dirtyMapValue;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
buffers.dirtyMap = archiveSection.original.dirtyMap.slice();
|
|
200
|
+
}
|
|
201
|
+
const flags = archiveSection.original.storeFlags();
|
|
202
|
+
return {
|
|
203
|
+
...(Object.keys(flags).length ? { flags } : {}),
|
|
204
|
+
...(Object.keys(palettes).length ? { palettes } : {}),
|
|
205
|
+
buffers,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SectorData } from "../../index";
|
|
2
2
|
import { ArchivedSectorData } from "../Archive.types";
|
|
3
3
|
type RunData = {
|
|
4
4
|
version?: number;
|
|
5
|
-
loadColumnState?: (data: Record<string, any>, sector: SectorData) => void;
|
|
6
|
-
loadSectionState?: (keys: string[], data: any[], section: VoxelDataArrays) => void;
|
|
7
5
|
};
|
|
8
|
-
export default function ImportSector(
|
|
6
|
+
export default function ImportSector(archivedSector: ArchivedSectorData, archiveData: RunData): SectorData;
|
|
9
7
|
export {};
|
|
@@ -1,227 +1,57 @@
|
|
|
1
1
|
import { Sector } from "../../index";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
ArrayBuffer.isView(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
(sector.palettes.state && sector.palettes.state.length <= 15)) &&
|
|
21
|
-
ArrayBuffer.isView(section.buffers.state)) {
|
|
22
|
-
section.buffers.state = getPaletteArray(Math.min(section.palettes.state?.length || Infinity, sector.palettes.state?.length || 0), section.buffers.state);
|
|
23
|
-
}
|
|
24
|
-
if (((section.palettes.mod && section.palettes.mod.length <= 15) ||
|
|
25
|
-
(sector.palettes.mod && sector.palettes.mod.length <= 15)) &&
|
|
26
|
-
ArrayBuffer.isView(section.buffers.mod)) {
|
|
27
|
-
section.buffers.mod = getPaletteArray(Math.min(section.palettes.mod?.length || Infinity, sector.palettes.mod?.length || 0), section.buffers.mod);
|
|
28
|
-
}
|
|
29
|
-
if (((section.palettes.secondaryState &&
|
|
30
|
-
section.palettes.secondaryState.length <= 15) ||
|
|
31
|
-
(sector.palettes.secondaryState &&
|
|
32
|
-
sector.palettes.secondaryState.length <= 15)) &&
|
|
33
|
-
((section.palettes.secondaryId &&
|
|
34
|
-
section.palettes.secondaryId.length <= 15) ||
|
|
35
|
-
(sector.palettes.secondaryId &&
|
|
36
|
-
sector.palettes.secondaryId.length <= 15)) &&
|
|
37
|
-
ArrayBuffer.isView(section.buffers.secondary)) {
|
|
38
|
-
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);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
const getImportedColumnData = (sector) => {
|
|
42
|
-
return {
|
|
43
|
-
sector,
|
|
44
|
-
idPalette: new StringPalette(sector.palettes.id),
|
|
45
|
-
secondaryId: sector.palettes.secondaryId
|
|
46
|
-
? new StringPalette(sector.palettes.secondaryId)
|
|
47
|
-
: undefined,
|
|
48
|
-
lightPalette: sector.palettes.light
|
|
49
|
-
? new NumberPalette(sector.palettes.light)
|
|
50
|
-
: undefined,
|
|
51
|
-
statePalette: sector.palettes.state
|
|
52
|
-
? new NumberPalette(sector.palettes.state)
|
|
53
|
-
: undefined,
|
|
54
|
-
modPalette: sector.palettes.mod
|
|
55
|
-
? new NumberPalette(sector.palettes.mod)
|
|
56
|
-
: undefined,
|
|
57
|
-
secondaryState: sector.palettes.secondaryState
|
|
58
|
-
? new NumberPalette(sector.palettes.secondaryState)
|
|
59
|
-
: undefined,
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
const getImportedSectionData = (section) => {
|
|
63
|
-
return {
|
|
64
|
-
section,
|
|
65
|
-
idPalette: section.palettes.id
|
|
66
|
-
? new NumberPalette(section.palettes.id)
|
|
67
|
-
: undefined,
|
|
68
|
-
lightPalette: section.palettes.light
|
|
69
|
-
? new NumberPalette(section.palettes.light)
|
|
70
|
-
: undefined,
|
|
71
|
-
statePalette: section.palettes.state
|
|
72
|
-
? new NumberPalette(section.palettes.state)
|
|
73
|
-
: undefined,
|
|
74
|
-
modPalette: section.palettes.mod
|
|
75
|
-
? new NumberPalette(section.palettes.mod)
|
|
76
|
-
: undefined,
|
|
77
|
-
secondaryState: section.palettes.secondaryState
|
|
78
|
-
? new NumberPalette(section.palettes.secondaryState)
|
|
79
|
-
: undefined,
|
|
80
|
-
secondaryId: section.palettes.secondaryId
|
|
81
|
-
? new NumberPalette(section.palettes.secondaryId)
|
|
82
|
-
: undefined,
|
|
83
|
-
};
|
|
84
|
-
};
|
|
85
|
-
const getId = (value, importedColumn, importedSection) => {
|
|
86
|
-
if (importedSection.section.buffers.state instanceof Uint16Array)
|
|
87
|
-
return value;
|
|
88
|
-
if (typeof importedSection.section.buffers.id == "number") {
|
|
89
|
-
return VoxelPalettesRegister.voxels.getNumberId(importedColumn.sector.palettes.id[importedSection.section.buffers.id]);
|
|
90
|
-
}
|
|
91
|
-
if (importedSection.idPalette) {
|
|
92
|
-
return VoxelPalettesRegister.voxels.getNumberId(importedColumn.idPalette.getStringId(importedSection.idPalette.getValue(value)));
|
|
93
|
-
}
|
|
94
|
-
return VoxelPalettesRegister.voxels.getNumberId(importedColumn.idPalette.getStringId(value));
|
|
95
|
-
};
|
|
96
|
-
const getLight = (value, importedColumn, importedSection) => {
|
|
97
|
-
if (importedSection.section.buffers.light instanceof Uint16Array)
|
|
98
|
-
return value;
|
|
99
|
-
if (typeof importedSection.section.buffers.light == "number") {
|
|
100
|
-
return value;
|
|
101
|
-
}
|
|
102
|
-
if (importedSection.lightPalette) {
|
|
103
|
-
return importedSection.lightPalette.getValue(value);
|
|
104
|
-
}
|
|
105
|
-
if (importedColumn.lightPalette) {
|
|
106
|
-
return importedColumn.lightPalette.getValue(value);
|
|
107
|
-
}
|
|
108
|
-
return value;
|
|
109
|
-
};
|
|
110
|
-
const getState = (voxelId, value, processedState, importedColumn, importedSection) => {
|
|
111
|
-
const voxelStringId = VoxelPalettesRegister.voxels.getStringId(voxelId);
|
|
112
|
-
if (!SchemaRegister.hasVoxelSchema(voxelStringId))
|
|
113
|
-
return value;
|
|
114
|
-
let stateId = -1;
|
|
115
|
-
if (importedSection.section.buffers.state instanceof Uint16Array ||
|
|
116
|
-
typeof importedSection.section.buffers.state == "number") {
|
|
117
|
-
stateId = value;
|
|
118
|
-
}
|
|
119
|
-
if (importedSection.statePalette) {
|
|
120
|
-
stateId = importedSection.statePalette.getValue(value);
|
|
121
|
-
}
|
|
122
|
-
else if (importedColumn.statePalette) {
|
|
123
|
-
stateId = value;
|
|
124
|
-
}
|
|
125
|
-
if (processedState[stateId] !== undefined)
|
|
126
|
-
return processedState[stateId];
|
|
127
|
-
value = SchemaRegister.getVoxelSchemas(voxelStringId).state.fromStateObject(importedColumn.sector.palettes.stateMap[stateId]);
|
|
128
|
-
processedState[stateId] = value;
|
|
129
|
-
return value;
|
|
130
|
-
};
|
|
131
|
-
const getMod = (voxelId, value, processedMod, importedColumn, importedSection) => {
|
|
132
|
-
const voxelStringId = VoxelPalettesRegister.voxels.getStringId(voxelId);
|
|
133
|
-
if (!SchemaRegister.hasVoxelSchema(voxelStringId))
|
|
134
|
-
return value;
|
|
135
|
-
let modId = -1;
|
|
136
|
-
if (importedSection.section.buffers.state instanceof Uint16Array ||
|
|
137
|
-
typeof importedSection.section.buffers.state == "number") {
|
|
138
|
-
modId = value;
|
|
139
|
-
}
|
|
140
|
-
if (importedSection.modPalette) {
|
|
141
|
-
modId = importedSection.modPalette.getValue(value);
|
|
142
|
-
}
|
|
143
|
-
else if (importedColumn.modPalette) {
|
|
144
|
-
modId = value;
|
|
145
|
-
}
|
|
146
|
-
if (processedMod[modId] !== undefined)
|
|
147
|
-
return processedMod[modId];
|
|
148
|
-
value = SchemaRegister.getVoxelSchemas(voxelStringId).mod.fromStateObject(importedColumn.sector.palettes.modMap[modId]);
|
|
149
|
-
processedMod[modId] = value;
|
|
150
|
-
return value;
|
|
151
|
-
};
|
|
152
|
-
const getSecondary = (voxelId, value, importedColumn, importedSection) => {
|
|
153
|
-
if (VoxelTagsRegister.VoxelTags[voxelId]["dve_can_have_secondary"]) {
|
|
154
|
-
if (typeof importedSection.section.buffers.secondary == "number") {
|
|
155
|
-
return VoxelPalettesRegister.voxels.getNumberId(importedColumn.sector.palettes.secondaryId[importedSection.section.buffers.secondary]);
|
|
2
|
+
import { ImportedSector } from "../Classes/ImportedSector";
|
|
3
|
+
export default function ImportSector(archivedSector, archiveData) {
|
|
4
|
+
const sector = new Sector(Sector.CreateNew(), [
|
|
5
|
+
archivedSector.location[0],
|
|
6
|
+
archivedSector.location[1],
|
|
7
|
+
archivedSector.location[2],
|
|
8
|
+
]);
|
|
9
|
+
sector.loadFlags(archivedSector.flags);
|
|
10
|
+
sector.loadTimestamps(archivedSector.timestamps);
|
|
11
|
+
const importedSector = new ImportedSector(archivedSector);
|
|
12
|
+
for (const importedSection of importedSector.sections) {
|
|
13
|
+
const archivedSection = importedSection.section;
|
|
14
|
+
const section = sector.sections[importedSection.sectionIndex];
|
|
15
|
+
archivedSection.flags && section.loadFlags(archivedSection.flags);
|
|
16
|
+
if (!ArrayBuffer.isView(archivedSection.buffers.buried)) {
|
|
17
|
+
for (let i = 0; i < section.buried.length; i++) {
|
|
18
|
+
section.buried[i] = archivedSection.buffers.buried || 0;
|
|
19
|
+
}
|
|
156
20
|
}
|
|
157
|
-
|
|
158
|
-
|
|
21
|
+
else {
|
|
22
|
+
for (let i = 0; i < section.buried.length; i++) {
|
|
23
|
+
section.buried[i] = archivedSection.buffers.buried[i];
|
|
24
|
+
}
|
|
159
25
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
//sectorStructInstance.deserialize(sector.sectorState);
|
|
180
|
-
}
|
|
181
|
-
else {
|
|
182
|
-
archiveData.loadColumnState(sector.sectorState, newSector);
|
|
183
|
-
}
|
|
184
|
-
const importedSector = getImportedColumnData(sector);
|
|
185
|
-
const processedState = {};
|
|
186
|
-
const processedMod = {};
|
|
187
|
-
for (let sectionIndex = 0; sectionIndex < sector.sections.length; sectionIndex++) {
|
|
188
|
-
const section = sector.sections[sectionIndex];
|
|
189
|
-
const importedSection = getImportedSectionData(section);
|
|
190
|
-
const newSection = newSector.sections[sectionIndex];
|
|
191
|
-
const sectionState = {};
|
|
192
|
-
for (let i = 0; i < sector.keys.sectionState.length; i++) {
|
|
193
|
-
sectionState[sector.keys.sectionState[i]] = section.state[i];
|
|
26
|
+
if (!ArrayBuffer.isView(archivedSection.buffers.voxelMap)) {
|
|
27
|
+
for (let i = 0; i < section.voxelMap.length; i++) {
|
|
28
|
+
section.voxelMap[i] = archivedSection.buffers.voxelMap || 0;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
for (let i = 0; i < section.voxelMap.length; i++) {
|
|
33
|
+
section.voxelMap[i] = archivedSection.buffers.voxelMap[i];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (!ArrayBuffer.isView(archivedSection.buffers.dirtyMap)) {
|
|
37
|
+
for (let i = 0; i < section.dirtyMap.length; i++) {
|
|
38
|
+
section.dirtyMap[i] = archivedSection.buffers.dirtyMap || 0;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
for (let i = 0; i < section.dirtyMap.length; i++) {
|
|
43
|
+
section.dirtyMap[i] = archivedSection.buffers.dirtyMap[i];
|
|
44
|
+
}
|
|
194
45
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
section.state,
|
|
203
|
-
newSection
|
|
204
|
-
);
|
|
205
|
-
} */
|
|
206
|
-
for (let i = 0; i < newSection.ids.length; i++) {
|
|
207
|
-
newSection.ids[i] = getId(typeof section.buffers.id == "number"
|
|
208
|
-
? section.buffers.id
|
|
209
|
-
: section.buffers.id[i], importedSector, importedSection);
|
|
210
|
-
newSection.light[i] = getLight(typeof section.buffers.light == "number"
|
|
211
|
-
? section.buffers.light
|
|
212
|
-
: section.buffers.light[i], importedSector, importedSection);
|
|
213
|
-
newSection.secondary[i] = getSecondary(newSection.ids[i], typeof section.buffers.secondary == "number"
|
|
214
|
-
? section.buffers.secondary
|
|
215
|
-
: section.buffers.secondary[i], importedSector, importedSection);
|
|
216
|
-
let secondary = VoxelTagsRegister.VoxelTags[newSection.ids[i]]["dve_can_have_secondary"] && newSection.secondary[i] > 0;
|
|
217
|
-
newSection.state[i] = getState(secondary ? newSection.secondary[i] : newSection.ids[i], typeof section.buffers.state == "number"
|
|
218
|
-
? section.buffers.state
|
|
219
|
-
: section.buffers.state[i], processedState, importedSector, importedSection);
|
|
220
|
-
newSection.mod[i] = getMod(secondary ? newSection.secondary[i] : newSection.ids[i], typeof section.buffers.mod == "number"
|
|
221
|
-
? section.buffers.mod
|
|
222
|
-
: section.buffers.mod[i], processedMod, importedSector, importedSection);
|
|
46
|
+
for (let i = 0; i < section.ids.length; i++) {
|
|
47
|
+
section.ids[i] = importedSection.getId(i);
|
|
48
|
+
section.level[i] = importedSection.getLevel(i);
|
|
49
|
+
section.light[i] = importedSection.getLight(i);
|
|
50
|
+
section.secondary[i] = importedSection.getSecondary(i);
|
|
51
|
+
section.state[i] = importedSection.getState(i);
|
|
52
|
+
section.mod[i] = importedSection.getMod(i);
|
|
223
53
|
}
|
|
224
|
-
newSector.sections[sectionIndex] = newSection;
|
|
225
54
|
}
|
|
226
|
-
|
|
55
|
+
sector.setBitFlag(Sector.FlagIds.stored, true);
|
|
56
|
+
return sector;
|
|
227
57
|
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { uint16To4CharString } from "./Shared";
|
|
2
|
+
function traverseSection(source, target) {
|
|
3
|
+
if (typeof source == "object" && typeof target == "object") {
|
|
4
|
+
if (Object.keys(source).length != Object.keys(target).length)
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
for (const key in source) {
|
|
8
|
+
if (!(key in target))
|
|
9
|
+
return false;
|
|
10
|
+
const sourceValue = source[key];
|
|
11
|
+
const targetValue = target[key];
|
|
12
|
+
if (!ArrayBuffer.isView(sourceValue) &&
|
|
13
|
+
typeof sourceValue === "object" &&
|
|
14
|
+
sourceValue !== null &&
|
|
15
|
+
!ArrayBuffer.isView(targetValue) &&
|
|
16
|
+
typeof targetValue == "object" &&
|
|
17
|
+
targetValue !== null) {
|
|
18
|
+
if (!traverseSection(sourceValue, targetValue))
|
|
19
|
+
return false;
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
if (typeof sourceValue === "number" ||
|
|
23
|
+
typeof sourceValue === "string" ||
|
|
24
|
+
typeof targetValue === "number" ||
|
|
25
|
+
typeof targetValue === "string") {
|
|
26
|
+
if (sourceValue !== targetValue)
|
|
27
|
+
return false;
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (sourceValue instanceof Uint8Array ||
|
|
31
|
+
sourceValue instanceof Uint16Array) {
|
|
32
|
+
if (!(targetValue instanceof sourceValue.constructor))
|
|
33
|
+
return false;
|
|
34
|
+
if (sourceValue.length !== targetValue.length)
|
|
35
|
+
return false;
|
|
36
|
+
let target = targetValue;
|
|
37
|
+
for (let i = 0; i < target.length; i++) {
|
|
38
|
+
if (sourceValue[i] != target[i])
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
export function compareSection(section1, section2) {
|
|
46
|
+
return traverseSection(section1, section2);
|
|
47
|
+
}
|
|
48
|
+
export function RemoveDuplicates(data) {
|
|
49
|
+
const duplicateSectionMap = new Map();
|
|
50
|
+
let duplicateSections = [];
|
|
51
|
+
for (let i = 0; i < data.sections.length; i++) {
|
|
52
|
+
for (let j = i + 1; j < data.sections.length; j++) {
|
|
53
|
+
const section1 = data.sections[i];
|
|
54
|
+
const section2 = data.sections[j];
|
|
55
|
+
if (typeof section1 == "string" || typeof section2 == "string")
|
|
56
|
+
continue;
|
|
57
|
+
let index = -1;
|
|
58
|
+
if (compareSection(section1, section2)) {
|
|
59
|
+
if (duplicateSectionMap.has(section2)) {
|
|
60
|
+
index = duplicateSectionMap.get(section2)[1];
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
let found = false;
|
|
64
|
+
for (let k = 0; k < duplicateSections.length; k++) {
|
|
65
|
+
if (compareSection(section1, duplicateSections[k])) {
|
|
66
|
+
index = k;
|
|
67
|
+
found = true;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (!found) {
|
|
71
|
+
duplicateSections.push(section1);
|
|
72
|
+
index = duplicateSections.length - 1;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
duplicateSectionMap.set(section1, [i, index]);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const sections = {};
|
|
80
|
+
for (let i = 0; i < data.sections.length; i++) {
|
|
81
|
+
const section = data.sections[i];
|
|
82
|
+
if (duplicateSectionMap.has(section)) {
|
|
83
|
+
const [, dupIndex] = duplicateSectionMap.get(section);
|
|
84
|
+
const id = uint16To4CharString(dupIndex);
|
|
85
|
+
data.sections[i] = id;
|
|
86
|
+
sections[id] = section;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
data.duplicates = {
|
|
90
|
+
sections,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ArchivedLightSegments } 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 getLightBuffer(light: ArchivedLightSegments, buffer: Uint16Array): Uint8Array;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { setNibbleArrayIndex } from "../../../Util/Binary/BinaryArrays";
|
|
2
|
+
import { VoxelLightData } from "../../../Voxels/Cursor/VoxelLightData";
|
|
3
|
+
const lightData = new VoxelLightData();
|
|
4
|
+
export const lightSegments = [
|
|
5
|
+
"sun",
|
|
6
|
+
"red",
|
|
7
|
+
"green",
|
|
8
|
+
"blue",
|
|
9
|
+
];
|
|
10
|
+
export const lightSemgnetGet = {
|
|
11
|
+
sun: (value) => lightData.getS(value),
|
|
12
|
+
red: (value) => lightData.getR(value),
|
|
13
|
+
green: (value) => lightData.getG(value),
|
|
14
|
+
blue: (value) => lightData.getB(value),
|
|
15
|
+
};
|
|
16
|
+
export const lightSemgnetSet = {
|
|
17
|
+
sun: (value, source) => lightData.setS(value, source),
|
|
18
|
+
red: (value, source) => lightData.setR(value, source),
|
|
19
|
+
green: (value, source) => lightData.setG(value, source),
|
|
20
|
+
blue: (value, source) => lightData.setB(value, source),
|
|
21
|
+
};
|
|
22
|
+
const charset = "0123456789ABCDEF";
|
|
23
|
+
export function uint16To4CharString(value) {
|
|
24
|
+
if (value < 0 || value > 0xffff) {
|
|
25
|
+
throw new RangeError("Value must be a 16-bit unsigned integer.");
|
|
26
|
+
}
|
|
27
|
+
const chars = [];
|
|
28
|
+
for (let i = 0; i < 4; i++) {
|
|
29
|
+
const charCode = (value >> (i * 4)) & 0x0f;
|
|
30
|
+
chars.unshift(charset[charCode]);
|
|
31
|
+
}
|
|
32
|
+
const result = chars.join("").replace(/^0+(?!$)/, "");
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
export function getLightBuffer(light, buffer) {
|
|
36
|
+
const array = new Uint8Array(buffer.length / 2);
|
|
37
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
38
|
+
let l = 0;
|
|
39
|
+
if (light == "sun")
|
|
40
|
+
l = lightData.getS(buffer[i]);
|
|
41
|
+
if (light == "red")
|
|
42
|
+
l = lightData.getR(buffer[i]);
|
|
43
|
+
if (light == "green")
|
|
44
|
+
l = lightData.getG(buffer[i]);
|
|
45
|
+
if (light == "blue")
|
|
46
|
+
l = lightData.getB(buffer[i]);
|
|
47
|
+
setNibbleArrayIndex(array, i, l);
|
|
48
|
+
}
|
|
49
|
+
return array;
|
|
50
|
+
}
|