@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,174 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { BuildTextureData, } from "./Functions/BuildTextureData.js";
|
|
2
|
+
const missingTexture = {
|
|
3
|
+
id: "dve_missing",
|
|
4
|
+
base64: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAEsGlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4KPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNS41LjAiPgogPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgeG1sbnM6ZXhpZj0iaHR0cDovL25zLmFkb2JlLmNvbS9leGlmLzEuMC8iCiAgICB4bWxuczp0aWZmPSJodHRwOi8vbnMuYWRvYmUuY29tL3RpZmYvMS4wLyIKICAgIHhtbG5zOnBob3Rvc2hvcD0iaHR0cDovL25zLmFkb2JlLmNvbS9waG90b3Nob3AvMS4wLyIKICAgIHhtbG5zOnhtcD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLyIKICAgIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIgogICAgeG1sbnM6c3RFdnQ9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZUV2ZW50IyIKICAgZXhpZjpQaXhlbFhEaW1lbnNpb249IjE2IgogICBleGlmOlBpeGVsWURpbWVuc2lvbj0iMTYiCiAgIGV4aWY6Q29sb3JTcGFjZT0iMSIKICAgdGlmZjpJbWFnZVdpZHRoPSIxNiIKICAgdGlmZjpJbWFnZUxlbmd0aD0iMTYiCiAgIHRpZmY6UmVzb2x1dGlvblVuaXQ9IjIiCiAgIHRpZmY6WFJlc29sdXRpb249IjcyLzEiCiAgIHRpZmY6WVJlc29sdXRpb249IjcyLzEiCiAgIHBob3Rvc2hvcDpDb2xvck1vZGU9IjMiCiAgIHBob3Rvc2hvcDpJQ0NQcm9maWxlPSJzUkdCIElFQzYxOTY2LTIuMSIKICAgeG1wOk1vZGlmeURhdGU9IjIwMjUtMDItMDRUMTM6MjY6MzYtMDU6MDAiCiAgIHhtcDpNZXRhZGF0YURhdGU9IjIwMjUtMDItMDRUMTM6MjY6MzYtMDU6MDAiPgogICA8eG1wTU06SGlzdG9yeT4KICAgIDxyZGY6U2VxPgogICAgIDxyZGY6bGkKICAgICAgc3RFdnQ6YWN0aW9uPSJwcm9kdWNlZCIKICAgICAgc3RFdnQ6c29mdHdhcmVBZ2VudD0iQWZmaW5pdHkgUGhvdG8gMS4xMC42IgogICAgICBzdEV2dDp3aGVuPSIyMDI1LTAyLTA0VDEzOjI2OjM2LTA1OjAwIi8+CiAgICA8L3JkZjpTZXE+CiAgIDwveG1wTU06SGlzdG9yeT4KICA8L3JkZjpEZXNjcmlwdGlvbj4KIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cjw/eHBhY2tldCBlbmQ9InIiPz6QxtZwAAABgWlDQ1BzUkdCIElFQzYxOTY2LTIuMQAAKJF1kb9LQlEUxz9qYfQDAyMaGiSsKcMMpJYGoyyoBjPIatHnr0Dt8Z4R0Rq0CgVRS7+G+gtqDZqDoCiCaK61qKXkdZ4KSuS5nHs+93vvOdx7LljDGSWrN3ghm8troWDAtRBZdNnfsGLDSSe9UUVXZ+YmwtS1rwcsZrzzmLXqn/vXWuIJXQFLk/Coomp54Unh6fW8avKucIeSjsaFz4X7Nbmg8L2px8r8anKqzD8ma+HQGFjbhV2pGo7VsJLWssLyctzZzJpSuY/5ktZEbn5OYo94NzohggRwMcU4Y/gZZERmPx58DMiKOvneUv4sq5KryKyygcYKKdLk6Rd1TaonJCZFT8jIsGH2/29f9eSQr1y9NQCNL4bx0Qv2HSgWDOP72DCKJ2B7hqtcNX/1CIY/RS9UNfchOLbg4rqqxfbgchu6ntSoFi1JNnFrMgnvZ9AWAectNC+Ve1bZ5/QRwpvyVTewfwB9ct6x/AtRCWfcDyqUNQAAAAlwSFlzAAALEwAACxMBAJqcGAAAACRJREFUKJFjPMWAHZjhEGfCIY4TjGogBjDiksAVP4PQD8NBAwBeSgHpmKHwOgAAAABJRU5ErkJggg==",
|
|
5
|
+
};
|
|
5
6
|
export class TextureManager {
|
|
6
|
-
static
|
|
7
|
-
static
|
|
8
|
-
static getTextureIndex(data) {
|
|
9
|
-
const [textureType, textureId, varation] = data;
|
|
10
|
-
const type = this.getTextureType(textureType);
|
|
11
|
-
if (!type)
|
|
12
|
-
return NaN;
|
|
13
|
-
return type.getTextureIndex(textureId, varation);
|
|
14
|
-
}
|
|
15
|
-
static _ready = false;
|
|
16
|
-
static isReady() {
|
|
17
|
-
return this._ready;
|
|
18
|
-
}
|
|
19
|
-
static async init() {
|
|
20
|
-
TextureBuilder.defineTextureDimensions(EngineSettings.settings.textures.textureSize);
|
|
21
|
-
for (const [key, type] of this.textureTypes) {
|
|
22
|
-
await type.build();
|
|
23
|
-
}
|
|
24
|
-
TextureRegister.setTextureIndex(this.generateTextureUVMap());
|
|
25
|
-
this._ready = true;
|
|
26
|
-
}
|
|
27
|
-
static generateTextureUVMap() {
|
|
28
|
-
const uvMap = {};
|
|
29
|
-
for (const [key, type] of this.textureTypes) {
|
|
30
|
-
uvMap[key] = type.getTextureIndexMap();
|
|
31
|
-
}
|
|
32
|
-
return uvMap;
|
|
33
|
-
}
|
|
34
|
-
static defineDefaultTexturePath(path) {
|
|
35
|
-
this.defaultTexturePath = path;
|
|
36
|
-
}
|
|
37
|
-
static getTextureData([type, id, segment]) {
|
|
38
|
-
const t = this.getTextureType(type);
|
|
39
|
-
if (!t)
|
|
40
|
-
return undefined;
|
|
41
|
-
return t.textureMap.get(id);
|
|
42
|
-
}
|
|
43
|
-
static getTextureType(id) {
|
|
44
|
-
const texture = this.textureTypes.get(id);
|
|
45
|
-
if (!texture)
|
|
46
|
-
return false;
|
|
47
|
-
return texture;
|
|
48
|
-
}
|
|
49
|
-
static getOrAddTextureType(id) {
|
|
50
|
-
const texture = this.textureTypes.get(id);
|
|
51
|
-
if (!texture)
|
|
52
|
-
return this.addTextureType(id);
|
|
53
|
-
return texture;
|
|
54
|
-
}
|
|
55
|
-
static addTextureType(id) {
|
|
56
|
-
const newType = new TextureArray(id);
|
|
57
|
-
this.textureTypes.set(id, newType);
|
|
58
|
-
return newType;
|
|
59
|
-
}
|
|
60
|
-
static clearTextureData() {
|
|
61
|
-
//
|
|
62
|
-
// this.textureTypes.forEach((_) => _.clearSegmentData());
|
|
63
|
-
}
|
|
7
|
+
static _textureTypes = new Map();
|
|
8
|
+
static _compiledTextures = new Map();
|
|
64
9
|
static registerTexture(textureData) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
const type = this.getOrAddTextureType(textureData.type);
|
|
76
|
-
if (!type)
|
|
77
|
-
return;
|
|
78
|
-
type.addTexture(textureData);
|
|
79
|
-
}
|
|
80
|
-
static getTexturePath(textureType, id, varation, segment = "main", frames) {
|
|
81
|
-
const data = this.getTextureData([textureType, id, segment]);
|
|
82
|
-
if (!data)
|
|
83
|
-
throw new Error(`Could not find data for ${textureType} ${id} ${varation}`);
|
|
84
|
-
let path = data.base64 &&
|
|
85
|
-
(Array.isArray(data.base64) ? data.base64[0] : data.base64);
|
|
86
|
-
if (path)
|
|
87
|
-
return path;
|
|
88
|
-
const type = this.textureTypes.get(textureType);
|
|
89
|
-
return type._getPath(data, varation, type.extension);
|
|
90
|
-
}
|
|
91
|
-
static async createCached() {
|
|
92
|
-
const cachedTextureData = [];
|
|
93
|
-
for (const [typeKey, type] of this.textureTypes) {
|
|
94
|
-
for (const baseData of type.textures) {
|
|
95
|
-
const data = structuredClone(baseData);
|
|
96
|
-
const id = baseData.id;
|
|
97
|
-
if (data.frames) {
|
|
98
|
-
const images = [];
|
|
99
|
-
for (let i = 1; i <= data.frames; i++) {
|
|
100
|
-
images.push(await TextureBuilder.getBase64(type._getPath(data, `${id}-${i}`, type.extension)));
|
|
101
|
-
}
|
|
102
|
-
data.base64 = images;
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
data.base64 = await TextureBuilder.getBase64(type._getPath(data, "default", type.extension));
|
|
106
|
-
}
|
|
107
|
-
if (data.variations) {
|
|
108
|
-
for (const varId in data.variations) {
|
|
109
|
-
const varation = data.variations[varId];
|
|
110
|
-
if (varation.frames) {
|
|
111
|
-
const images = [];
|
|
112
|
-
for (let i = 1; i <= varation.frames; i++) {
|
|
113
|
-
images.push(await TextureBuilder.getBase64(type._getPath(data, `${varId}-${i}`, type.extension)));
|
|
114
|
-
}
|
|
115
|
-
varation.base64 = images;
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
varation.base64 = await TextureBuilder.getBase64(type._getPath(data, varId, type.extension));
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
cachedTextureData.push(data);
|
|
10
|
+
for (const texture of textureData) {
|
|
11
|
+
const typeId = texture.type || "dve_voxel";
|
|
12
|
+
let type = this._textureTypes.get(typeId);
|
|
13
|
+
if (!type) {
|
|
14
|
+
type = [missingTexture];
|
|
15
|
+
this._textureTypes.set(typeId, type);
|
|
123
16
|
}
|
|
17
|
+
type.push(texture);
|
|
124
18
|
}
|
|
125
|
-
return cachedTextureData;
|
|
126
19
|
}
|
|
127
|
-
static
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
const rawData = await TextureBuilder.getRawData(type._getPath(data, "default", type.extension));
|
|
145
|
-
data.rawData = rawData;
|
|
146
|
-
map.set(key, rawData);
|
|
147
|
-
}
|
|
148
|
-
if (data.variations) {
|
|
149
|
-
for (const varId in data.variations) {
|
|
150
|
-
const varation = data.variations[varId];
|
|
151
|
-
if (!varation.includeInRawDataMap)
|
|
152
|
-
continue;
|
|
153
|
-
const key = `${type.id}|${data.id}|${varId}`;
|
|
154
|
-
if (data.frames) {
|
|
155
|
-
for (let i = 1; i <= data.frames; i++) {
|
|
156
|
-
const rawData = await TextureBuilder.getRawData(type._getPath(data, `${key}-${i}`, type.extension));
|
|
157
|
-
data.rawData = rawData;
|
|
158
|
-
map.set(`${key}-${i}`, rawData);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
const rawData = await TextureBuilder.getRawData(type._getPath(data, varId, type.extension));
|
|
163
|
-
data.rawData = rawData;
|
|
164
|
-
map.set(key, rawData);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
20
|
+
static getTexture(id) {
|
|
21
|
+
const type = this._compiledTextures.get(id);
|
|
22
|
+
if (!type)
|
|
23
|
+
throw new Error(`Compiled texture with id ${id} does not exist`);
|
|
24
|
+
return type;
|
|
25
|
+
}
|
|
26
|
+
static async compiledTextures(props = {}) {
|
|
27
|
+
for (const [type, data] of this._textureTypes) {
|
|
28
|
+
const compiled = await BuildTextureData({
|
|
29
|
+
type,
|
|
30
|
+
textures: data,
|
|
31
|
+
...props,
|
|
32
|
+
});
|
|
33
|
+
this._compiledTextures.set(type, compiled);
|
|
169
34
|
}
|
|
170
|
-
return map;
|
|
171
35
|
}
|
|
172
36
|
}
|
|
173
|
-
TextureManager.getOrAddTextureType("dve_voxel");
|
|
174
|
-
TextureManager.getOrAddTextureType("dve_node");
|
package/Tools/Brush/Brush.d.ts
CHANGED
|
@@ -3,11 +3,10 @@ import { WorldCursor } from "../../World/Cursor/WorldCursor.js";
|
|
|
3
3
|
import { VoxelCursor } from "../../Voxels/Cursor/VoxelCursor.js";
|
|
4
4
|
export declare class BrushTool {
|
|
5
5
|
data: PaintVoxelData;
|
|
6
|
-
dimension:
|
|
6
|
+
dimension: number;
|
|
7
7
|
x: number;
|
|
8
8
|
y: number;
|
|
9
9
|
z: number;
|
|
10
|
-
name: string;
|
|
11
10
|
voxelCursor: VoxelCursor;
|
|
12
11
|
dataCursor: WorldCursor;
|
|
13
12
|
setXYZ(x: number, y: number, z: number): this;
|
|
@@ -19,6 +18,7 @@ export declare class BrushTool {
|
|
|
19
18
|
setId(id: string): this;
|
|
20
19
|
setName(name: string): this;
|
|
21
20
|
setSecondaryId(id: string): this;
|
|
21
|
+
setSecondaryName(name: string): this;
|
|
22
22
|
setShapeState(state: number): this;
|
|
23
23
|
setLevel(level: number): this;
|
|
24
24
|
setLevelState(levelState: number): this;
|
|
@@ -29,6 +29,6 @@ export declare class BrushTool {
|
|
|
29
29
|
_erase(): void;
|
|
30
30
|
paint(): this;
|
|
31
31
|
erase(): this;
|
|
32
|
-
start(dimension:
|
|
32
|
+
start(dimension: number, x: number, y: number, z: number): this;
|
|
33
33
|
stop(): this;
|
|
34
34
|
}
|
package/Tools/Brush/Brush.js
CHANGED
|
@@ -7,17 +7,18 @@ const air = [0, 0, 0, 0, 0, 0];
|
|
|
7
7
|
export class BrushTool {
|
|
8
8
|
data = {
|
|
9
9
|
id: airId,
|
|
10
|
+
name: "",
|
|
10
11
|
state: 0,
|
|
11
12
|
secondaryVoxelId: "",
|
|
13
|
+
secondaryVoxeName: "",
|
|
12
14
|
level: 0,
|
|
13
15
|
levelState: 0,
|
|
14
16
|
mod: 0,
|
|
15
17
|
};
|
|
16
|
-
dimension =
|
|
18
|
+
dimension = 0;
|
|
17
19
|
x = 0;
|
|
18
20
|
y = 0;
|
|
19
21
|
z = 0;
|
|
20
|
-
name = airId;
|
|
21
22
|
voxelCursor = new VoxelCursor();
|
|
22
23
|
dataCursor = new WorldCursor();
|
|
23
24
|
setXYZ(x, y, z) {
|
|
@@ -30,11 +31,22 @@ export class BrushTool {
|
|
|
30
31
|
WorldRegister.sectors.new(this.dimension, this.x, this.y, this.z);
|
|
31
32
|
}
|
|
32
33
|
setData(data) {
|
|
33
|
-
this.
|
|
34
|
+
this.clear();
|
|
35
|
+
if (data.name) {
|
|
36
|
+
this.setName(data.name);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
if (data.id)
|
|
40
|
+
this.setId(data.id);
|
|
41
|
+
}
|
|
42
|
+
if (data.secondaryVoxeName) {
|
|
43
|
+
this.setSecondaryName(data.secondaryVoxeName);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
if (data.secondaryVoxelId)
|
|
47
|
+
this.setSecondaryId(data.secondaryVoxelId);
|
|
48
|
+
}
|
|
34
49
|
this.data.state = data.state ? data.state : 0;
|
|
35
|
-
this.data.secondaryVoxelId = data.secondaryVoxelId
|
|
36
|
-
? data.secondaryVoxelId
|
|
37
|
-
: airId;
|
|
38
50
|
this.data.level = data.level ? data.level : 0;
|
|
39
51
|
this.data.levelState = data.levelState ? data.levelState : 0;
|
|
40
52
|
this.data.mod = data.mod ? data.mod : 0;
|
|
@@ -62,15 +74,34 @@ export class BrushTool {
|
|
|
62
74
|
}
|
|
63
75
|
setId(id) {
|
|
64
76
|
this.data.id = id;
|
|
77
|
+
this.data.name = VoxelPalettesRegister.voxelIdToNameMap.get(id);
|
|
65
78
|
return this;
|
|
66
79
|
}
|
|
67
80
|
setName(name) {
|
|
68
|
-
this.data.id = VoxelPalettesRegister.
|
|
69
|
-
this.name = name;
|
|
81
|
+
this.data.id = VoxelPalettesRegister.voxelNametoIdMap.get(name);
|
|
82
|
+
this.data.name = name;
|
|
70
83
|
return this;
|
|
71
84
|
}
|
|
72
85
|
setSecondaryId(id) {
|
|
73
86
|
this.data.secondaryVoxelId = id;
|
|
87
|
+
if (id) {
|
|
88
|
+
this.data.secondaryVoxeName =
|
|
89
|
+
VoxelPalettesRegister.voxelIdToNameMap.get(id);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
this.data.secondaryVoxeName = "";
|
|
93
|
+
}
|
|
94
|
+
return this;
|
|
95
|
+
}
|
|
96
|
+
setSecondaryName(name) {
|
|
97
|
+
if (name) {
|
|
98
|
+
this.data.secondaryVoxelId =
|
|
99
|
+
VoxelPalettesRegister.voxelNametoIdMap.get(name);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
this.data.secondaryVoxelId = "";
|
|
103
|
+
}
|
|
104
|
+
this.data.secondaryVoxeName = name;
|
|
74
105
|
return this;
|
|
75
106
|
}
|
|
76
107
|
setShapeState(state) {
|
|
@@ -91,6 +122,7 @@ export class BrushTool {
|
|
|
91
122
|
}
|
|
92
123
|
clear() {
|
|
93
124
|
this.data.id = "dve_air";
|
|
125
|
+
this.data.name = "";
|
|
94
126
|
this.data.secondaryVoxelId = "";
|
|
95
127
|
this.data.level = 0;
|
|
96
128
|
this.data.levelState = 0;
|
package/Tools/Tasks/TasksTool.js
CHANGED
|
@@ -62,11 +62,13 @@ class VoxelTasks {
|
|
|
62
62
|
update;
|
|
63
63
|
paint;
|
|
64
64
|
erease;
|
|
65
|
+
logic;
|
|
65
66
|
constructor(tool) {
|
|
66
67
|
this.tool = tool;
|
|
67
68
|
this.update = new TaskToolTask(TasksIds.VoxelUpdate, tool.threads);
|
|
68
69
|
this.paint = new TaskToolTask(TasksIds.VoxelPaint, tool.threads);
|
|
69
70
|
this.erease = new TaskToolTask(TasksIds.VoxelErease, tool.threads);
|
|
71
|
+
this.logic = new TaskToolTask(TasksIds.LogicUpdate, tool.threads);
|
|
70
72
|
}
|
|
71
73
|
}
|
|
72
74
|
class BuildTask {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function getBitArrayIndex(data: Uint8Array, arrayIndex: number): number;
|
|
2
|
+
export declare function setBitArrayIndex(data: Uint8Array, arrayIndex: number, value: number): void;
|
|
3
|
+
export declare function getNibbleArrayIndex(data: Uint8Array, arrayIndex: number): number;
|
|
4
|
+
export declare function setNibbleArrayIndex(data: Uint8Array, arrayIndex: number, value: number): void;
|
|
5
|
+
export declare function getHalfNibbleArrayIndex(data: Uint8Array, arrayIndex: number): number;
|
|
6
|
+
export declare function setHalfNibbleArrayIndex(data: Uint8Array, arrayIndex: number, value: number): void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { getBitValue, setBitValue } from "./BinaryFunctions";
|
|
2
|
+
export function getBitArrayIndex(data, arrayIndex) {
|
|
3
|
+
const arrayByteIndex = Math.floor(arrayIndex / 8);
|
|
4
|
+
const bitPosition = arrayIndex % 8;
|
|
5
|
+
return getBitValue(data[arrayByteIndex], bitPosition, 1);
|
|
6
|
+
}
|
|
7
|
+
export function setBitArrayIndex(data, arrayIndex, value) {
|
|
8
|
+
const arrayByteIndex = Math.floor(arrayIndex / 8);
|
|
9
|
+
const bitPosition = arrayIndex % 8;
|
|
10
|
+
data[arrayByteIndex] = setBitValue(data[arrayByteIndex], bitPosition, value & 1, 1);
|
|
11
|
+
}
|
|
12
|
+
export function getNibbleArrayIndex(data, arrayIndex) {
|
|
13
|
+
return getBitValue(data[(arrayIndex / 2) >> 0], arrayIndex % 2 === 0 ? 4 : 0, 4);
|
|
14
|
+
}
|
|
15
|
+
export function setNibbleArrayIndex(data, arrayIndex, value) {
|
|
16
|
+
const arrayByteIndex = (arrayIndex / 2) >> 0;
|
|
17
|
+
data[arrayByteIndex] = setBitValue(data[arrayByteIndex], arrayIndex % 2 === 0 ? 4 : 0, value, 4);
|
|
18
|
+
}
|
|
19
|
+
export function getHalfNibbleArrayIndex(data, arrayIndex) {
|
|
20
|
+
return getBitValue(data[(arrayIndex / 4) >> 0], (arrayIndex % 4) * 2, 2);
|
|
21
|
+
}
|
|
22
|
+
export function setHalfNibbleArrayIndex(data, arrayIndex, value) {
|
|
23
|
+
const arrayByteIndex = (arrayIndex / 4) >> 0;
|
|
24
|
+
data[arrayByteIndex] = setBitValue(data[arrayByteIndex], (arrayIndex % 4) * 2, value, 2);
|
|
25
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export declare enum BinaryBufferTypes {
|
|
2
|
+
Value = 0,
|
|
3
|
+
BitArray = 1,
|
|
4
|
+
HalfNibbleArray = 2,
|
|
5
|
+
NibbleArray = 4,
|
|
6
|
+
ByteArray = 8,
|
|
7
|
+
ShortArray = 16
|
|
8
|
+
}
|
|
9
|
+
export interface BinaryBufferData {
|
|
10
|
+
type: BinaryBufferTypes;
|
|
11
|
+
buffer: number | ArrayBufferLike;
|
|
12
|
+
}
|
|
13
|
+
export interface BinaryBuffer extends BinaryBufferData {
|
|
14
|
+
}
|
|
15
|
+
export declare class BinaryBuffer {
|
|
16
|
+
static ByteArrayMax: number;
|
|
17
|
+
static NibbleArrayMax: number;
|
|
18
|
+
static HalfNibbleArrayMax: number;
|
|
19
|
+
static BitArrayMax: number;
|
|
20
|
+
static DetermineSubByteArray: (paletteSize: number) => BinaryBufferTypes | null;
|
|
21
|
+
static CreateBufferForType(type: BinaryBufferTypes, length: number): Uint16Array | Uint8Array;
|
|
22
|
+
static GetConvertedBufferSize(source: Uint8Array | Uint16Array, type: BinaryBufferTypes): number;
|
|
23
|
+
static GetIndexLength(source: Uint8Array | Uint16Array, type: BinaryBufferTypes): number;
|
|
24
|
+
static ReadBufferAtIndex(source: Uint8Array | Uint16Array, type: BinaryBufferTypes, index: number): number;
|
|
25
|
+
static SetBufferAtIndex(source: Uint8Array | Uint16Array, type: BinaryBufferTypes, index: number, value: number): number | void;
|
|
26
|
+
static Convert(source: Uint8Array | Uint16Array, sourceType: BinaryBufferTypes, destinationType: BinaryBufferTypes): Uint16Array | Uint8Array;
|
|
27
|
+
static Create(data: Partial<BinaryBufferData>): BinaryBufferData;
|
|
28
|
+
bufferView: Uint8Array | Uint16Array;
|
|
29
|
+
constructor(data: BinaryBufferData);
|
|
30
|
+
getValue(index: number): number;
|
|
31
|
+
toJSON(): {
|
|
32
|
+
buffer: number | ArrayBufferLike;
|
|
33
|
+
type: BinaryBufferTypes;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { getBitArrayIndex, getHalfNibbleArrayIndex, getNibbleArrayIndex, setBitArrayIndex, setHalfNibbleArrayIndex, setNibbleArrayIndex, } from "./BinaryArrays";
|
|
2
|
+
export var BinaryBufferTypes;
|
|
3
|
+
(function (BinaryBufferTypes) {
|
|
4
|
+
BinaryBufferTypes[BinaryBufferTypes["Value"] = 0] = "Value";
|
|
5
|
+
BinaryBufferTypes[BinaryBufferTypes["BitArray"] = 1] = "BitArray";
|
|
6
|
+
BinaryBufferTypes[BinaryBufferTypes["HalfNibbleArray"] = 2] = "HalfNibbleArray";
|
|
7
|
+
BinaryBufferTypes[BinaryBufferTypes["NibbleArray"] = 4] = "NibbleArray";
|
|
8
|
+
BinaryBufferTypes[BinaryBufferTypes["ByteArray"] = 8] = "ByteArray";
|
|
9
|
+
BinaryBufferTypes[BinaryBufferTypes["ShortArray"] = 16] = "ShortArray";
|
|
10
|
+
})(BinaryBufferTypes || (BinaryBufferTypes = {}));
|
|
11
|
+
export class BinaryBuffer {
|
|
12
|
+
static ByteArrayMax = 256;
|
|
13
|
+
static NibbleArrayMax = 16;
|
|
14
|
+
static HalfNibbleArrayMax = 4;
|
|
15
|
+
static BitArrayMax = 2;
|
|
16
|
+
static DetermineSubByteArray = (paletteSize) => {
|
|
17
|
+
if (paletteSize == BinaryBuffer.BitArrayMax)
|
|
18
|
+
return BinaryBufferTypes.BitArray;
|
|
19
|
+
if (paletteSize > BinaryBuffer.BitArrayMax &&
|
|
20
|
+
paletteSize <= BinaryBuffer.HalfNibbleArrayMax)
|
|
21
|
+
return BinaryBufferTypes.HalfNibbleArray;
|
|
22
|
+
if (paletteSize > BinaryBuffer.HalfNibbleArrayMax &&
|
|
23
|
+
paletteSize <= BinaryBuffer.NibbleArrayMax)
|
|
24
|
+
return BinaryBufferTypes.NibbleArray;
|
|
25
|
+
if (paletteSize > BinaryBuffer.NibbleArrayMax &&
|
|
26
|
+
paletteSize <= BinaryBuffer.ByteArrayMax)
|
|
27
|
+
return BinaryBufferTypes.ByteArray;
|
|
28
|
+
return null;
|
|
29
|
+
};
|
|
30
|
+
static CreateBufferForType(type, length) {
|
|
31
|
+
if (type == BinaryBufferTypes.ShortArray)
|
|
32
|
+
return new Uint16Array(length);
|
|
33
|
+
return new Uint8Array(length);
|
|
34
|
+
}
|
|
35
|
+
static GetConvertedBufferSize(source, type) {
|
|
36
|
+
if (type == BinaryBufferTypes.ShortArray ||
|
|
37
|
+
type == BinaryBufferTypes.ByteArray)
|
|
38
|
+
return source.length;
|
|
39
|
+
if (type == BinaryBufferTypes.BitArray)
|
|
40
|
+
return source.length / 8;
|
|
41
|
+
if (type == BinaryBufferTypes.HalfNibbleArray)
|
|
42
|
+
return source.length / 4;
|
|
43
|
+
if (type == BinaryBufferTypes.NibbleArray)
|
|
44
|
+
return source.length / 2;
|
|
45
|
+
if (type == BinaryBufferTypes.Value)
|
|
46
|
+
return 1;
|
|
47
|
+
return source.length;
|
|
48
|
+
}
|
|
49
|
+
static GetIndexLength(source, type) {
|
|
50
|
+
if (type == BinaryBufferTypes.ShortArray ||
|
|
51
|
+
type == BinaryBufferTypes.ByteArray)
|
|
52
|
+
return source.length;
|
|
53
|
+
if (type == BinaryBufferTypes.BitArray)
|
|
54
|
+
return source.length * 8;
|
|
55
|
+
if (type == BinaryBufferTypes.HalfNibbleArray)
|
|
56
|
+
return source.length * 4;
|
|
57
|
+
if (type == BinaryBufferTypes.NibbleArray)
|
|
58
|
+
return source.length * 2;
|
|
59
|
+
if (type == BinaryBufferTypes.Value)
|
|
60
|
+
return 1;
|
|
61
|
+
return source.length;
|
|
62
|
+
}
|
|
63
|
+
static ReadBufferAtIndex(source, type, index) {
|
|
64
|
+
if (type == BinaryBufferTypes.ShortArray ||
|
|
65
|
+
type == BinaryBufferTypes.ByteArray)
|
|
66
|
+
return source[index];
|
|
67
|
+
if (type == BinaryBufferTypes.BitArray)
|
|
68
|
+
return getBitArrayIndex(source, index);
|
|
69
|
+
if (type == BinaryBufferTypes.NibbleArray)
|
|
70
|
+
return getNibbleArrayIndex(source, index);
|
|
71
|
+
if (type == BinaryBufferTypes.HalfNibbleArray)
|
|
72
|
+
return getHalfNibbleArrayIndex(source, index);
|
|
73
|
+
return source[index];
|
|
74
|
+
}
|
|
75
|
+
static SetBufferAtIndex(source, type, index, value) {
|
|
76
|
+
if (type == BinaryBufferTypes.ShortArray ||
|
|
77
|
+
type == BinaryBufferTypes.ByteArray) {
|
|
78
|
+
return (source[index] = value);
|
|
79
|
+
}
|
|
80
|
+
if (type == BinaryBufferTypes.BitArray)
|
|
81
|
+
return setBitArrayIndex(source, index, value);
|
|
82
|
+
if (type == BinaryBufferTypes.NibbleArray)
|
|
83
|
+
return setNibbleArrayIndex(source, index, value);
|
|
84
|
+
if (type == BinaryBufferTypes.HalfNibbleArray)
|
|
85
|
+
return setHalfNibbleArrayIndex(source, index, value);
|
|
86
|
+
return source[index];
|
|
87
|
+
}
|
|
88
|
+
static Convert(source, sourceType, destinationType) {
|
|
89
|
+
if (sourceType == destinationType ||
|
|
90
|
+
(sourceType == BinaryBufferTypes.ShortArray &&
|
|
91
|
+
destinationType == BinaryBufferTypes.ByteArray) ||
|
|
92
|
+
(sourceType == BinaryBufferTypes.ByteArray &&
|
|
93
|
+
destinationType == BinaryBufferTypes.ShortArray)) {
|
|
94
|
+
const destination = this.CreateBufferForType(destinationType, this.GetConvertedBufferSize(source, destinationType));
|
|
95
|
+
destination.set(source);
|
|
96
|
+
return destination;
|
|
97
|
+
}
|
|
98
|
+
const length = this.GetIndexLength(source, sourceType);
|
|
99
|
+
const destination = this.CreateBufferForType(destinationType, this.GetConvertedBufferSize(source, destinationType));
|
|
100
|
+
for (let i = 0; i < length; i++) {
|
|
101
|
+
this.SetBufferAtIndex(destination, destinationType, i, this.ReadBufferAtIndex(source, sourceType, i));
|
|
102
|
+
}
|
|
103
|
+
return destination;
|
|
104
|
+
}
|
|
105
|
+
static Create(data) {
|
|
106
|
+
return {
|
|
107
|
+
buffer: 0,
|
|
108
|
+
type: BinaryBufferTypes.Value,
|
|
109
|
+
...data,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
bufferView;
|
|
113
|
+
constructor(data) {
|
|
114
|
+
this.buffer = data.buffer;
|
|
115
|
+
this.type = data.type;
|
|
116
|
+
if (typeof this.buffer !== "number") {
|
|
117
|
+
if (this.type == BinaryBufferTypes.ShortArray) {
|
|
118
|
+
this.bufferView = new Uint16Array(this.buffer);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
this.bufferView = new Uint8Array(this.buffer);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
getValue(index) {
|
|
126
|
+
if (typeof this.buffer == "number")
|
|
127
|
+
return this.buffer;
|
|
128
|
+
return BinaryBuffer.ReadBufferAtIndex(this.bufferView, this.type, index);
|
|
129
|
+
}
|
|
130
|
+
toJSON() {
|
|
131
|
+
return {
|
|
132
|
+
buffer: this.buffer,
|
|
133
|
+
type: this.type,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export declare function getBitValue(data: number, bitIndex: number, bitSize: number): number;
|
|
2
2
|
export declare function setBitValue(data: number, bitIndex: number, value: number, bitSize: number): number;
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function setBitArrayIndex(data: Uint8Array, arrayIndex: number, value: number): void;
|
|
3
|
+
export declare function forceMultipleOf2(n: number): number;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function getBitValue(data, bitIndex, bitSize) {
|
|
2
|
+
const mask = (1 << bitSize) - 1;
|
|
3
|
+
return (data >>> bitIndex) & mask;
|
|
4
|
+
}
|
|
5
|
+
export function setBitValue(data, bitIndex, value, bitSize) {
|
|
6
|
+
const mask = (1 << bitSize) - 1;
|
|
7
|
+
return (data & ~(mask << bitIndex)) | ((value & mask) << bitIndex);
|
|
8
|
+
}
|
|
9
|
+
export function forceMultipleOf2(n) {
|
|
10
|
+
return n % 2 === 0 ? n : n + 1;
|
|
11
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A class to help with indexing a full flat binary tree defined by the number of levels it has.
|
|
3
3
|
*/
|
|
4
|
-
declare class FlatBinaryTreeIndex {
|
|
4
|
+
export declare class FlatBinaryTreeIndex {
|
|
5
5
|
levels: number;
|
|
6
6
|
constructor(levels: number);
|
|
7
7
|
/** Gets the number of nodes at a level of the tree */
|
|
@@ -44,35 +44,3 @@ declare class FlatBinaryTreeIndex {
|
|
|
44
44
|
/** Gets the total number of nodes in the tree */
|
|
45
45
|
getTotalSize(): number;
|
|
46
46
|
}
|
|
47
|
-
export declare class StructCursor {
|
|
48
|
-
data: Float32Array;
|
|
49
|
-
get minX(): number;
|
|
50
|
-
get minY(): number;
|
|
51
|
-
get minZ(): number;
|
|
52
|
-
get maxX(): number;
|
|
53
|
-
get maxY(): number;
|
|
54
|
-
get maxZ(): number;
|
|
55
|
-
get voxelIndex(): number;
|
|
56
|
-
get active(): number;
|
|
57
|
-
get nodeType(): number;
|
|
58
|
-
trueIndex: number;
|
|
59
|
-
private index;
|
|
60
|
-
setIndex(index: number): void;
|
|
61
|
-
constructor(data: Float32Array);
|
|
62
|
-
setActive(): void;
|
|
63
|
-
setVoxelIndex(value: number): void;
|
|
64
|
-
setInnerNode(): void;
|
|
65
|
-
setGeomtryNode(): void;
|
|
66
|
-
updateMin(x: number, y: number, z: number): void;
|
|
67
|
-
updateMax(x: number, y: number, z: number): void;
|
|
68
|
-
}
|
|
69
|
-
export declare class VoxelMeshBVHBuilder {
|
|
70
|
-
static AABBStructByteSize: number;
|
|
71
|
-
treeIndex: FlatBinaryTreeIndex;
|
|
72
|
-
tree: Float32Array;
|
|
73
|
-
structCursor: StructCursor;
|
|
74
|
-
indices: Uint32Array;
|
|
75
|
-
reset(): void;
|
|
76
|
-
updateVoxel(voxelX: number, voxelY: number, voxelZ: number, meshIndex: number, indicesStart: number, indicesEnd: number, minX: number, minY: number, minZ: number, maxX: number, maxY: number, maxZ: number): void;
|
|
77
|
-
}
|
|
78
|
-
export {};
|