@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,23 +1,21 @@
|
|
|
1
1
|
import { BrushTool } from "../../../Tools/Brush/Brush.js";
|
|
2
|
-
import { SubstanceDataTool } from "../../../Tools/Data/SubstanceDataTool.js";
|
|
3
2
|
import { WorldCursor } from "../../../World/index.js";
|
|
4
3
|
export class FlowManager {
|
|
5
4
|
static _brush = new BrushTool();
|
|
6
5
|
static _sDataTool = new WorldCursor();
|
|
7
6
|
static _nDataTool = new WorldCursor();
|
|
8
|
-
static _substanceTool = new SubstanceDataTool();
|
|
9
7
|
static setVoxel(tasks, vox, level, levelState, x, y, z) {
|
|
10
8
|
/* this.sunCheck(tasks, x, y, z);
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
9
|
+
SunRemove(tasks);
|
|
10
|
+
this._brush.setId(vox).setXYZ(x, y, z).paint();
|
|
11
|
+
this._sDataTool.loadInAt(x, y, z);
|
|
12
|
+
this._sDataTool
|
|
13
|
+
.setLevel(level)
|
|
14
|
+
.setLevelState(levelState)
|
|
15
|
+
.setLight(this.getAbsorbLight(x, y, z))
|
|
16
|
+
.commit();
|
|
17
|
+
|
|
18
|
+
SunUpdate(tasks); */
|
|
21
19
|
}
|
|
22
20
|
static setDimension(dimension) {
|
|
23
21
|
// this._sDataTool.setDimension(dimension);
|
|
@@ -27,43 +25,44 @@ export class FlowManager {
|
|
|
27
25
|
}
|
|
28
26
|
static removeVoxel(tasks, x, y, z) {
|
|
29
27
|
/* for (const n of $3dCardinalNeighbors) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
28
|
+
const nx = x + n[0];
|
|
29
|
+
const ny = y + n[1];
|
|
30
|
+
const nz = z + n[2];
|
|
31
|
+
if (!this._nDataTool.loadInAt(nx, ny, nz)) continue;
|
|
32
|
+
|
|
33
|
+
const l = this._nDataTool.getLight();
|
|
34
|
+
|
|
35
|
+
if (l <= 0) continue;
|
|
36
|
+
|
|
37
|
+
if (this.lightData.getS(l) > 0) {
|
|
38
|
+
tasks.sun.update.push(nx, ny, nz);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (this.lightData.hasRGBLight(l)) {
|
|
42
|
+
tasks.rgb.update.push(nx, ny, nz);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
this._nDataTool.loadInAt(x, y, z);
|
|
46
|
+
const currentLight = this._nDataTool.getLight();
|
|
47
|
+
this._brush.setXYZ(x, y, z).erase();
|
|
48
|
+
this._nDataTool.clear().loadInAt(x, y, z);
|
|
49
|
+
this._nDataTool.setLight(currentLight).commit();
|
|
50
|
+
tasks.rgb.remove.push(x, y, z);
|
|
51
|
+
RGBRemove(tasks);
|
|
52
|
+
SunUpdate(tasks);
|
|
53
|
+
RGBUpdate(tasks); */
|
|
56
54
|
}
|
|
57
55
|
static getFlowRate(substance) {
|
|
58
|
-
this._substanceTool.setSubstanceFromString(substance);
|
|
59
|
-
return this._substanceTool.getFlowRate();
|
|
56
|
+
// this._substanceTool.setSubstanceFromString(substance);
|
|
57
|
+
// return this._substanceTool.getFlowRate();
|
|
58
|
+
return 0;
|
|
60
59
|
}
|
|
61
60
|
static getVoxel(x, y, z) {
|
|
62
61
|
/* if (!this._sDataTool.loadInAt(x, y, z)) return false;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
if (!this._sDataTool.isRenderable()) return false;
|
|
63
|
+
|
|
64
|
+
const substance = this._sDataTool.getSubstnaceData();
|
|
65
|
+
if (!substance.isLiquid()) return false; */
|
|
67
66
|
return this._sDataTool;
|
|
68
67
|
}
|
|
69
68
|
static setLevel(level, x, y, z) {
|
|
@@ -72,39 +71,39 @@ export class FlowManager {
|
|
|
72
71
|
}
|
|
73
72
|
static getLevel(vox, x, y, z) {
|
|
74
73
|
/* if (!this._nDataTool.loadInAt(x, y, z)) return -2;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
74
|
+
const voxel = this._nDataTool.getStringId();
|
|
75
|
+
if (this._nDataTool.isAir()) {
|
|
76
|
+
return 0;
|
|
77
|
+
}
|
|
78
|
+
if (voxel == vox) {
|
|
79
|
+
return this._nDataTool.getLevel();
|
|
80
|
+
}
|
|
81
|
+
return -1; */
|
|
83
82
|
}
|
|
84
83
|
static getLevelState(vox, x, y, z) {
|
|
85
84
|
/* if (!this._nDataTool.loadInAt(x, y, z)) return -2;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
85
|
+
const voxel = this._nDataTool.getStringId();
|
|
86
|
+
if (voxel == vox) {
|
|
87
|
+
return this._nDataTool.getLevelState();
|
|
88
|
+
}
|
|
89
|
+
if (this._nDataTool.isAir()) {
|
|
90
|
+
return -1;
|
|
91
|
+
}
|
|
92
|
+
return -3; */
|
|
94
93
|
}
|
|
95
94
|
static canFlowOutwardTest(vox, x, y, z) {
|
|
96
95
|
/* const level = this.getLevel(vox, x, y - 1, z);
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
96
|
+
if (level == -1) {
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
return false; */
|
|
101
100
|
}
|
|
102
101
|
static flowDownTest(vox, x, y, z) {
|
|
103
102
|
/* const level = this.getLevel(vox, x, y - 1, z);
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
103
|
+
if (level >= 0) {
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
return false; */
|
|
108
107
|
}
|
|
109
108
|
static wait(ms) {
|
|
110
109
|
return new Promise((resolve, reject) => setTimeout(resolve, ms));
|
|
@@ -114,29 +113,29 @@ export class FlowManager {
|
|
|
114
113
|
];
|
|
115
114
|
static getAbsorbLight(x, y, z) {
|
|
116
115
|
/* for (const n of $3dCardinalNeighbors) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
}
|
|
116
|
+
if (!n[0] && !n[1] && !n[2]) continue;
|
|
117
|
+
if (!this._nDataTool.loadInAt(x + n[0], y + n[1], z + n[2])) continue;
|
|
118
|
+
let l = this._nDataTool.getLight();
|
|
119
|
+
if (l <= 0) continue;
|
|
120
|
+
const v = this.lightData.getLightValues(l);
|
|
121
|
+
for (let i = 0; i < 4; i++) {
|
|
122
|
+
if (this._lightValues[i] < v[i]) {
|
|
123
|
+
this._lightValues[i] = v[i];
|
|
127
124
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
let brightest = this.lightData.setLightValues(this._lightValues);
|
|
128
|
+
for (let i = 0; i < 4; i++) {
|
|
129
|
+
this._lightValues[i] = 0;
|
|
130
|
+
} */
|
|
132
131
|
// return this.lightData.minusOneForAll(2);
|
|
133
132
|
}
|
|
134
133
|
static sunCheck(tasks, x, y, z) {
|
|
135
134
|
/* if (!this._nDataTool.loadInAt(x, y - 1, z)) return;
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
135
|
+
if (!this._nDataTool.isAir()) return;
|
|
136
|
+
const l = this._nDataTool.getLight();
|
|
137
|
+
if (this.lightData.getS(l) == 0xf) {
|
|
138
|
+
tasks.sun.remove.push(x, y - 1, z);
|
|
139
|
+
} */
|
|
141
140
|
}
|
|
142
141
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { WorldSpaces } from "../../../World/WorldSpaces";
|
|
2
2
|
import { WorldRegister } from "../../../World/WorldRegister";
|
|
3
|
-
import { SectionHeightMap } from "../../../World/Section/SectionHeightMap";
|
|
4
3
|
import { EngineSettings } from "../../../Settings/EngineSettings";
|
|
5
4
|
import { SunRemove, SunUpdate } from "../Illumanation/SunUpdate";
|
|
6
5
|
import { RGBRemove, RGBUpdate } from "../Illumanation/RGBUpdate";
|
|
@@ -118,7 +117,7 @@ export function WorldFlow(task) {
|
|
|
118
117
|
const section = sector.sections[i];
|
|
119
118
|
if (!section)
|
|
120
119
|
continue;
|
|
121
|
-
let [minY, maxY] =
|
|
120
|
+
let [minY, maxY] = section.getMinMax();
|
|
122
121
|
const cx = sector.position[0];
|
|
123
122
|
const cy = sector.position[1] + i * WorldSpaces.section.bounds.y;
|
|
124
123
|
const cz = sector.position[2];
|
|
@@ -130,7 +129,7 @@ export function WorldFlow(task) {
|
|
|
130
129
|
const voxel = task.nDataCursor.getVoxel(x, y, z);
|
|
131
130
|
if (!voxel || voxel.isAir())
|
|
132
131
|
continue;
|
|
133
|
-
if (voxel.getSubstanceData()
|
|
132
|
+
if (voxel.getSubstanceData()["dve_is_liquid"]) {
|
|
134
133
|
for (let i = 0; i < 5; i++) {
|
|
135
134
|
const nVoxel = task.nDataCursor.getVoxel(x + flowUpdateChecks[i][0], y + flowUpdateChecks[i][1], z + flowUpdateChecks[i][2]);
|
|
136
135
|
if (nVoxel && nVoxel.isAir()) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { WorldSpaces } from "../../../World/WorldSpaces";
|
|
2
2
|
import { WorldRegister } from "../../../World/WorldRegister";
|
|
3
3
|
import { SectionCursor } from "../../../World/Cursor/SectionCursor";
|
|
4
|
-
import { SectionHeightMap } from "../../../World/Section/SectionHeightMap";
|
|
5
4
|
import { EngineSettings } from "../../../Settings/EngineSettings";
|
|
6
5
|
import { RGBUpdate } from "./RGBUpdate";
|
|
7
6
|
const sectionCursor = new SectionCursor();
|
|
@@ -20,7 +19,7 @@ export function WorldRGB(task) {
|
|
|
20
19
|
if (!section)
|
|
21
20
|
continue;
|
|
22
21
|
sectionCursor.setSection(section);
|
|
23
|
-
let [minY, maxY] =
|
|
22
|
+
let [minY, maxY] = section.getMinMax();
|
|
24
23
|
const cx = sector.position[0];
|
|
25
24
|
const cy = sector.position[1] + i * WorldSpaces.section.bounds.y;
|
|
26
25
|
const cz = sector.position[2];
|
|
@@ -2,22 +2,22 @@ import { Threads } from "@amodx/threads";
|
|
|
2
2
|
import { TasksIds } from "../TasksIds";
|
|
3
3
|
import { VoxelUpdate, EreaseAndUpdate, PaintAndUpdate } from "./VoxelUpdate";
|
|
4
4
|
export default function (props) {
|
|
5
|
-
Threads.registerTask(TasksIds.VoxelUpdate, async (data) => {
|
|
5
|
+
Threads.registerTask(TasksIds.VoxelUpdate, async (data, origin) => {
|
|
6
6
|
const tasks = await VoxelUpdate(data);
|
|
7
7
|
if (!tasks)
|
|
8
8
|
return;
|
|
9
|
-
props.onDone(tasks);
|
|
9
|
+
props.onDone(tasks, origin);
|
|
10
10
|
});
|
|
11
|
-
Threads.registerTask(TasksIds.VoxelErease, async (data) => {
|
|
11
|
+
Threads.registerTask(TasksIds.VoxelErease, async (data, origin) => {
|
|
12
12
|
const tasks = await EreaseAndUpdate(data);
|
|
13
13
|
if (!tasks)
|
|
14
14
|
return;
|
|
15
|
-
props.onDone(tasks);
|
|
15
|
+
props.onDone(tasks, origin);
|
|
16
16
|
});
|
|
17
|
-
Threads.registerTask(TasksIds.VoxelPaint, async (data) => {
|
|
17
|
+
Threads.registerTask(TasksIds.VoxelPaint, async (data, origin) => {
|
|
18
18
|
const tasks = await PaintAndUpdate(data);
|
|
19
19
|
if (!tasks)
|
|
20
20
|
return;
|
|
21
|
-
props.onDone(tasks);
|
|
21
|
+
props.onDone(tasks, origin);
|
|
22
22
|
});
|
|
23
23
|
}
|
|
@@ -15,10 +15,12 @@ declare class UpdatedBounds {
|
|
|
15
15
|
_task: UpdateTask;
|
|
16
16
|
min: Vector3Like;
|
|
17
17
|
max: Vector3Like;
|
|
18
|
+
dimension: string;
|
|
18
19
|
constructor(_task: UpdateTask);
|
|
19
|
-
|
|
20
|
+
start(dimension?: string): void;
|
|
20
21
|
update(x: number, y: number, z: number): void;
|
|
21
22
|
getSections(): Vec3Array[];
|
|
23
|
+
markSectionsAsDirty(): void;
|
|
22
24
|
}
|
|
23
25
|
export declare class UpdateTask {
|
|
24
26
|
flow: FlowQueues;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { WorldCursor } from "../../World/Cursor/WorldCursor";
|
|
2
2
|
import { Vector3Like } from "@amodx/math";
|
|
3
3
|
import { WorldSpaces } from "../../World/WorldSpaces";
|
|
4
|
+
import { WorldRegister } from "../../World/WorldRegister";
|
|
4
5
|
export class TaskMap {
|
|
5
6
|
_map = [];
|
|
6
7
|
get size() {
|
|
@@ -34,10 +35,12 @@ class UpdatedBounds {
|
|
|
34
35
|
_task;
|
|
35
36
|
min = Vector3Like.Clone(InfinityVec3);
|
|
36
37
|
max = Vector3Like.Clone(NegativeInfinityVec3);
|
|
38
|
+
dimension = "main";
|
|
37
39
|
constructor(_task) {
|
|
38
40
|
this._task = _task;
|
|
39
41
|
}
|
|
40
|
-
|
|
42
|
+
start(dimension) {
|
|
43
|
+
this.dimension = dimension || "main";
|
|
41
44
|
Vector3Like.Copy(this.min, InfinityVec3);
|
|
42
45
|
Vector3Like.Copy(this.max, NegativeInfinityVec3);
|
|
43
46
|
}
|
|
@@ -76,6 +79,29 @@ class UpdatedBounds {
|
|
|
76
79
|
}
|
|
77
80
|
return sectionPositions;
|
|
78
81
|
}
|
|
82
|
+
markSectionsAsDirty() {
|
|
83
|
+
const minSectionPos = WorldSpaces.section.getPosition(this.min.x - 1, this.min.y - 1, this.min.z - 1, tempPosition);
|
|
84
|
+
const minX = minSectionPos.x;
|
|
85
|
+
const minY = minSectionPos.y;
|
|
86
|
+
const minZ = minSectionPos.z;
|
|
87
|
+
const maxSectionPos = WorldSpaces.section.getPosition(this.max.x + 1, this.max.y + 1, this.max.z + 1, tempPosition);
|
|
88
|
+
const maxX = maxSectionPos.x;
|
|
89
|
+
const maxY = maxSectionPos.y;
|
|
90
|
+
const maxZ = maxSectionPos.z;
|
|
91
|
+
for (let x = minX; x <= maxX; x += WorldSpaces.section.bounds.x) {
|
|
92
|
+
for (let z = minZ; z <= maxZ; z += WorldSpaces.section.bounds.z) {
|
|
93
|
+
for (let y = minY; y <= maxY; y += WorldSpaces.section.bounds.y) {
|
|
94
|
+
if (!WorldSpaces.world.inBounds(x, y, z))
|
|
95
|
+
continue;
|
|
96
|
+
const sector = WorldRegister.sectors.get(this.dimension, x, y, z);
|
|
97
|
+
if (!sector)
|
|
98
|
+
continue;
|
|
99
|
+
const section = sector.getSection(x, y, z);
|
|
100
|
+
section.setDirty(true);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
79
105
|
}
|
|
80
106
|
export class UpdateTask {
|
|
81
107
|
flow = new FlowQueues();
|
|
@@ -96,13 +122,13 @@ export class UpdateTask {
|
|
|
96
122
|
this.flow.update.map.start(origin[1], origin[2], origin[3]);
|
|
97
123
|
this.flow.remove.map.start(origin[1], origin[2], origin[3]);
|
|
98
124
|
this.flow.remove.noRemoveMap.start(origin[1], origin[2], origin[3]);
|
|
125
|
+
this.bounds.start(origin[0]);
|
|
99
126
|
this.clear();
|
|
100
127
|
}
|
|
101
128
|
clear() {
|
|
102
129
|
this.rgb.clear();
|
|
103
130
|
this.sun.clear();
|
|
104
131
|
this.flow.clear();
|
|
105
|
-
this.bounds.reset();
|
|
106
132
|
}
|
|
107
133
|
}
|
|
108
134
|
class FlowQueues {
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { EngineSettings as ES } from "../../Settings/EngineSettings.js";
|
|
2
2
|
import { $3dCardinalNeighbors } from "../../Math/CardinalNeighbors.js";
|
|
3
3
|
import { UpdateTask } from "./UpdateTask.js";
|
|
4
|
-
import { SubstanceDataTool } from "../../Tools/Data/SubstanceDataTool.js";
|
|
5
4
|
import { RGBRemove, RGBUpdate } from "../Propagation/Illumanation/RGBUpdate.js";
|
|
6
5
|
import { SunRemove, SunUpdate } from "../Propagation/Illumanation/SunUpdate.js";
|
|
7
6
|
import { FlowUpdate } from "../Propagation/Flow/FlowUpdate.js";
|
|
8
7
|
import { FlowRemove } from "../Propagation/Flow/FlowRemove.js";
|
|
9
8
|
const tasks = new UpdateTask();
|
|
10
|
-
const substanceData = new SubstanceDataTool();
|
|
11
9
|
const updateLightTask = (tasks) => {
|
|
12
10
|
let doRGB = ES.doRGBPropagation;
|
|
13
11
|
let doSun = ES.doSunPropagation;
|
|
@@ -38,9 +36,9 @@ export async function EreaseAndUpdate(location) {
|
|
|
38
36
|
let voxel = tasks.sDataCursor.getVoxel(x, y, z);
|
|
39
37
|
if (!voxel)
|
|
40
38
|
return false;
|
|
41
|
-
substanceData
|
|
39
|
+
const substanceData = voxel.getSubstanceData();
|
|
42
40
|
if (!voxel.isAir() && ES.doFlow && voxel.isRenderable()) {
|
|
43
|
-
if (substanceData
|
|
41
|
+
if (substanceData["dve_is_liquid"]) {
|
|
44
42
|
FlowRemove(tasks);
|
|
45
43
|
return tasks;
|
|
46
44
|
}
|
|
@@ -70,6 +68,13 @@ export async function EreaseAndUpdate(location) {
|
|
|
70
68
|
SunUpdate(tasks);
|
|
71
69
|
}
|
|
72
70
|
}
|
|
71
|
+
tasks.bounds.update(x, y, z);
|
|
72
|
+
tasks.bounds.update(x + 1, y + 1, z + 1);
|
|
73
|
+
for (let i = 0; i < $3dCardinalNeighbors.length; i++) {
|
|
74
|
+
tasks.sDataCursor
|
|
75
|
+
.getVoxel($3dCardinalNeighbors[i][0] + x, $3dCardinalNeighbors[i][1] + y, $3dCardinalNeighbors[i][2] + z)
|
|
76
|
+
?.updateVoxel(2);
|
|
77
|
+
}
|
|
73
78
|
return tasks;
|
|
74
79
|
}
|
|
75
80
|
export async function PaintAndUpdate(data) {
|
|
@@ -107,6 +112,7 @@ export async function PaintAndUpdate(data) {
|
|
|
107
112
|
voxel.setLevel(raw[2]);
|
|
108
113
|
voxel.setState(raw[3]);
|
|
109
114
|
voxel.setMod(raw[4]);
|
|
115
|
+
voxel.process();
|
|
110
116
|
if (raw[3] > 0 && voxel.canHaveSecondaryVoxel()) {
|
|
111
117
|
voxel.setSecondary(true);
|
|
112
118
|
voxel.setId(raw[5]);
|
|
@@ -128,11 +134,17 @@ export async function PaintAndUpdate(data) {
|
|
|
128
134
|
}
|
|
129
135
|
voxel = tasks.sDataCursor.getVoxel(x, y, z);
|
|
130
136
|
if (ES.doFlow) {
|
|
131
|
-
if (!voxel.isAir() &&
|
|
132
|
-
substanceData.setSubstance(voxel.getSubstance()).isLiquid()) {
|
|
137
|
+
if (!voxel.isAir() && voxel.getSubstanceData()["dve_is_liquid"]) {
|
|
133
138
|
FlowUpdate(tasks);
|
|
134
139
|
}
|
|
135
140
|
}
|
|
141
|
+
tasks.bounds.update(x, y, z);
|
|
142
|
+
tasks.bounds.update(x + 1, y + 1, z + 1);
|
|
143
|
+
for (let i = 0; i < $3dCardinalNeighbors.length; i++) {
|
|
144
|
+
tasks.sDataCursor
|
|
145
|
+
.getVoxel($3dCardinalNeighbors[i][0] + x, $3dCardinalNeighbors[i][1] + y, $3dCardinalNeighbors[i][2] + z)
|
|
146
|
+
?.updateVoxel(2);
|
|
147
|
+
}
|
|
136
148
|
return tasks;
|
|
137
149
|
}
|
|
138
150
|
export async function VoxelUpdate(data) {
|
|
@@ -155,9 +167,11 @@ export async function VoxelUpdate(data) {
|
|
|
155
167
|
}
|
|
156
168
|
}
|
|
157
169
|
if (ES.doFlow) {
|
|
158
|
-
if (
|
|
170
|
+
if (voxel.getSubstanceData()["dve_is_solid"]) {
|
|
159
171
|
FlowUpdate(tasks);
|
|
160
172
|
}
|
|
161
173
|
}
|
|
174
|
+
tasks.bounds.update(x, y, z);
|
|
175
|
+
tasks.bounds.update(x + 1, y + 1, z + 1);
|
|
162
176
|
return tasks;
|
|
163
177
|
}
|
|
@@ -56,7 +56,7 @@ export class WorldGenBrush extends BrushTool {
|
|
|
56
56
|
}
|
|
57
57
|
getUpdatedSections() {
|
|
58
58
|
const queue = this.tasks.bounds.getSections();
|
|
59
|
-
this.tasks.bounds.
|
|
59
|
+
this.tasks.bounds.start();
|
|
60
60
|
return queue;
|
|
61
61
|
}
|
|
62
62
|
update() {
|
|
@@ -64,6 +64,7 @@ export class WorldGenBrush extends BrushTool {
|
|
|
64
64
|
if (!voxel)
|
|
65
65
|
return false;
|
|
66
66
|
const sl = voxel.getLight();
|
|
67
|
+
voxel.updateVoxel(2);
|
|
67
68
|
if (lightData.hasRGBLight(sl)) {
|
|
68
69
|
this.tasks.rgb.update.push(this.x, this.y, this.z);
|
|
69
70
|
// Propagation.instance.rgbUpdate(this.tasks);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TemplateVoxelCursor } from "./TemplateVoxelCursor";
|
|
2
|
-
import { DataCursorInterface } from "../../
|
|
2
|
+
import { DataCursorInterface } from "../../Voxels/Cursor/DataCursor.interface";
|
|
3
3
|
import { FullVoxelTemplate } from "Templates/FullVoxelTemplate";
|
|
4
|
-
export declare class TemplateCursor
|
|
4
|
+
export declare class TemplateCursor implements DataCursorInterface {
|
|
5
5
|
_voxelIndex: number;
|
|
6
6
|
_template: FullVoxelTemplate | null;
|
|
7
7
|
private voxel;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { TemplateVoxelCursor } from "./TemplateVoxelCursor";
|
|
2
|
-
|
|
3
|
-
export class TemplateCursor extends DataCursorInterface {
|
|
2
|
+
export class TemplateCursor {
|
|
4
3
|
_voxelIndex = 0;
|
|
5
4
|
_template = null;
|
|
6
5
|
voxel = new TemplateVoxelCursor(this);
|
|
@@ -2,7 +2,7 @@ import { Flat3DIndex, Traverse } from "@amodx/math";
|
|
|
2
2
|
import { StringPalette } from "../../Util/StringPalette";
|
|
3
3
|
import { VoxelTemplate } from "../VoxelTemplate";
|
|
4
4
|
import { NumberPalette } from "../../Util/NumberPalette";
|
|
5
|
-
import { convertToPaletteBuffer } from "../../
|
|
5
|
+
import { convertToPaletteBuffer } from "../../Util/Binary/Palettes";
|
|
6
6
|
import { WorldCursor } from "../../World";
|
|
7
7
|
export default function CreateTemplate(dimension, start, end) {
|
|
8
8
|
const dataTool = new WorldCursor();
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Flat3DIndex, Traverse } from "@amodx/math";
|
|
2
2
|
import { StringPalette } from "../Util/StringPalette";
|
|
3
3
|
import { NumberPalette } from "../Util/NumberPalette";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { getPaletteArray } from "../Data/Functions/Palettes";
|
|
4
|
+
import { getPaletteArray } from "../Util/Binary/Palettes";
|
|
5
|
+
import { VoxelPalettesRegister } from "../Voxels/Data/VoxelPalettesRegister";
|
|
6
|
+
import { VoxelTagsRegister } from "../Voxels/Data/VoxelTagsRegister";
|
|
8
7
|
export class VoxelTemplate {
|
|
9
8
|
index = Flat3DIndex.GetXZYOrder();
|
|
10
9
|
size;
|
|
@@ -49,7 +48,7 @@ export class VoxelTemplate {
|
|
|
49
48
|
}
|
|
50
49
|
getId(index) {
|
|
51
50
|
const ids = this.ids;
|
|
52
|
-
return
|
|
51
|
+
return VoxelPalettesRegister.voxels.getNumberId(this.idPalette.getStringId(typeof ids == "number" ? ids : ids[index]));
|
|
53
52
|
}
|
|
54
53
|
getState(index) {
|
|
55
54
|
const state = this.state;
|
|
@@ -65,9 +64,8 @@ export class VoxelTemplate {
|
|
|
65
64
|
}
|
|
66
65
|
getSecondary(id, index) {
|
|
67
66
|
const secondary = this.secondary;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
return VoxelPalette.ids.getNumberId(this.secondaryIdPalette.getStringId(typeof secondary == "number" ? secondary : secondary[index]));
|
|
67
|
+
if (VoxelTagsRegister.VoxelTags[id]["dve_can_have_secondary"]) {
|
|
68
|
+
return VoxelPalettesRegister.voxels.getNumberId(this.secondaryIdPalette.getStringId(typeof secondary == "number" ? secondary : secondary[index]));
|
|
71
69
|
}
|
|
72
70
|
return this.secondaryStatePalette.getValue(typeof secondary == "number" ? secondary : secondary[index]);
|
|
73
71
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Vec2Array } from "@amodx/math";
|
|
2
|
+
import { TextureId } from "../../Textures/Texture.types";
|
|
3
|
+
import { CompiledTextureAnimation } from "./CompiledTextureAnimation";
|
|
4
|
+
import { TextureAnimationTexture } from "./TextureAnimationTexture";
|
|
5
|
+
export declare class CompiledTexture {
|
|
6
|
+
id: string;
|
|
7
|
+
static GetAtlasIndex: (x: number, y: number, boundsX: number) => number;
|
|
8
|
+
static GetAtlasPosition: (index: number, boundsX: number, position?: Vec2Array) => Vec2Array;
|
|
9
|
+
images: HTMLImageElement[];
|
|
10
|
+
atlasSizeMap: Record<string, [width: number, height: number]>;
|
|
11
|
+
textureMap: Record<string, number>;
|
|
12
|
+
animations: CompiledTextureAnimation[];
|
|
13
|
+
shaderTexture: any;
|
|
14
|
+
animatedTexture: TextureAnimationTexture;
|
|
15
|
+
constructor(id: string);
|
|
16
|
+
getTextureIndex(id: TextureId): number;
|
|
17
|
+
getTexturePath(id: TextureId): string;
|
|
18
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { TextureAnimationTexture } from "./TextureAnimationTexture";
|
|
2
|
+
export class CompiledTexture {
|
|
3
|
+
id;
|
|
4
|
+
static GetAtlasIndex = (x, y, boundsX) => x + y * boundsX;
|
|
5
|
+
static GetAtlasPosition = (index, boundsX, position = [0, 0]) => {
|
|
6
|
+
position[1] = Math.floor(index / boundsX);
|
|
7
|
+
position[0] = Math.floor(index % boundsX);
|
|
8
|
+
return position;
|
|
9
|
+
};
|
|
10
|
+
images = [];
|
|
11
|
+
atlasSizeMap = {};
|
|
12
|
+
textureMap = {};
|
|
13
|
+
animations = [];
|
|
14
|
+
shaderTexture;
|
|
15
|
+
animatedTexture;
|
|
16
|
+
constructor(id) {
|
|
17
|
+
this.id = id;
|
|
18
|
+
this.animatedTexture = new TextureAnimationTexture(this);
|
|
19
|
+
}
|
|
20
|
+
getTextureIndex(id) {
|
|
21
|
+
let finalId = "";
|
|
22
|
+
let frameIndex = 0;
|
|
23
|
+
if (!Array.isArray(id)) {
|
|
24
|
+
finalId = id;
|
|
25
|
+
}
|
|
26
|
+
if (Array.isArray(id)) {
|
|
27
|
+
finalId = id[0];
|
|
28
|
+
if (typeof id[1] == "number")
|
|
29
|
+
frameIndex = id[1];
|
|
30
|
+
if (Array.isArray(id[1]))
|
|
31
|
+
frameIndex = CompiledTexture.GetAtlasIndex(id[1][0], id[1][1], this.atlasSizeMap[finalId][0]);
|
|
32
|
+
if (typeof id[1] == "string") {
|
|
33
|
+
finalId = `${id[0]}:${id[1]}`;
|
|
34
|
+
if (typeof id[2] == "number")
|
|
35
|
+
frameIndex = id[2];
|
|
36
|
+
if (Array.isArray(id[2]))
|
|
37
|
+
frameIndex = CompiledTexture.GetAtlasIndex(id[2][0], id[2][1], this.atlasSizeMap[finalId][0]);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const index = this.textureMap[finalId];
|
|
41
|
+
if (index === undefined) {
|
|
42
|
+
console.warn(`Texture with id [passed in: ${id.toString()}] [final: ${finalId}] does not exist on compiled texture [${this.id}]`);
|
|
43
|
+
return 0;
|
|
44
|
+
}
|
|
45
|
+
return index + frameIndex;
|
|
46
|
+
}
|
|
47
|
+
getTexturePath(id) {
|
|
48
|
+
return this.images[this.getTextureIndex(id)].src;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare class CompiledTextureAnimation {
|
|
2
|
+
textureIndex: number;
|
|
3
|
+
_frames: number[];
|
|
4
|
+
_times: number[];
|
|
5
|
+
_currentTime: number;
|
|
6
|
+
_frameIndex: number;
|
|
7
|
+
_current: number;
|
|
8
|
+
_animatedTextureIndex: number;
|
|
9
|
+
constructor(textureIndex: number);
|
|
10
|
+
tick(delta: number): boolean;
|
|
11
|
+
getIndex(): number;
|
|
12
|
+
}
|