@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
package/Tools/Brush/Brush.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { PaintVoxelData, RawVoxelData } from "../../Voxels/Types/Voxel.types.js";
|
|
2
2
|
import { WorldCursor } from "../../World/Cursor/WorldCursor.js";
|
|
3
|
-
import { SubstanceDataTool } from "../../Tools/Data/SubstanceDataTool.js";
|
|
4
3
|
import { VoxelCursor } from "../../Voxels/Cursor/VoxelCursor.js";
|
|
5
4
|
export declare class BrushTool {
|
|
6
5
|
data: PaintVoxelData;
|
|
@@ -8,10 +7,8 @@ export declare class BrushTool {
|
|
|
8
7
|
x: number;
|
|
9
8
|
y: number;
|
|
10
9
|
z: number;
|
|
11
|
-
name: string;
|
|
12
10
|
voxelCursor: VoxelCursor;
|
|
13
11
|
dataCursor: WorldCursor;
|
|
14
|
-
substanceData: SubstanceDataTool;
|
|
15
12
|
setXYZ(x: number, y: number, z: number): this;
|
|
16
13
|
newSector(): void;
|
|
17
14
|
setData(data: Partial<PaintVoxelData>): this;
|
|
@@ -21,6 +18,7 @@ export declare class BrushTool {
|
|
|
21
18
|
setId(id: string): this;
|
|
22
19
|
setName(name: string): this;
|
|
23
20
|
setSecondaryId(id: string): this;
|
|
21
|
+
setSecondaryName(name: string): this;
|
|
24
22
|
setShapeState(state: number): this;
|
|
25
23
|
setLevel(level: number): this;
|
|
26
24
|
setLevelState(levelState: number): this;
|
package/Tools/Brush/Brush.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { VoxelPalette } from "../../Voxels/Palettes/VoxelPalette.js";
|
|
2
1
|
import { WorldCursor } from "../../World/Cursor/WorldCursor.js";
|
|
3
|
-
import { SubstanceDataTool } from "../../Tools/Data/SubstanceDataTool.js";
|
|
4
2
|
import { VoxelCursor } from "../../Voxels/Cursor/VoxelCursor.js";
|
|
5
3
|
import { WorldRegister } from "../../World/WorldRegister.js";
|
|
4
|
+
import { VoxelPalettesRegister } from "../../Voxels/Data/VoxelPalettesRegister.js";
|
|
6
5
|
const airId = "dve_air";
|
|
7
6
|
const air = [0, 0, 0, 0, 0, 0];
|
|
8
7
|
export class BrushTool {
|
|
9
8
|
data = {
|
|
10
9
|
id: airId,
|
|
10
|
+
name: "",
|
|
11
11
|
state: 0,
|
|
12
12
|
secondaryVoxelId: "",
|
|
13
|
+
secondaryVoxeName: "",
|
|
13
14
|
level: 0,
|
|
14
15
|
levelState: 0,
|
|
15
16
|
mod: 0,
|
|
@@ -18,10 +19,8 @@ export class BrushTool {
|
|
|
18
19
|
x = 0;
|
|
19
20
|
y = 0;
|
|
20
21
|
z = 0;
|
|
21
|
-
name = airId;
|
|
22
22
|
voxelCursor = new VoxelCursor();
|
|
23
23
|
dataCursor = new WorldCursor();
|
|
24
|
-
substanceData = new SubstanceDataTool();
|
|
25
24
|
setXYZ(x, y, z) {
|
|
26
25
|
this.x = x;
|
|
27
26
|
this.y = y;
|
|
@@ -32,11 +31,22 @@ export class BrushTool {
|
|
|
32
31
|
WorldRegister.sectors.new(this.dimension, this.x, this.y, this.z);
|
|
33
32
|
}
|
|
34
33
|
setData(data) {
|
|
35
|
-
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
|
+
}
|
|
36
49
|
this.data.state = data.state ? data.state : 0;
|
|
37
|
-
this.data.secondaryVoxelId = data.secondaryVoxelId
|
|
38
|
-
? data.secondaryVoxelId
|
|
39
|
-
: airId;
|
|
40
50
|
this.data.level = data.level ? data.level : 0;
|
|
41
51
|
this.data.levelState = data.levelState ? data.levelState : 0;
|
|
42
52
|
this.data.mod = data.mod ? data.mod : 0;
|
|
@@ -64,15 +74,34 @@ export class BrushTool {
|
|
|
64
74
|
}
|
|
65
75
|
setId(id) {
|
|
66
76
|
this.data.id = id;
|
|
77
|
+
this.data.name = VoxelPalettesRegister.voxelIdToNameMap.get(id);
|
|
67
78
|
return this;
|
|
68
79
|
}
|
|
69
80
|
setName(name) {
|
|
70
|
-
this.data.id =
|
|
71
|
-
this.name = name;
|
|
81
|
+
this.data.id = VoxelPalettesRegister.voxelNametoIdMap.get(name);
|
|
82
|
+
this.data.name = name;
|
|
72
83
|
return this;
|
|
73
84
|
}
|
|
74
85
|
setSecondaryId(id) {
|
|
75
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;
|
|
76
105
|
return this;
|
|
77
106
|
}
|
|
78
107
|
setShapeState(state) {
|
|
@@ -93,6 +122,7 @@ export class BrushTool {
|
|
|
93
122
|
}
|
|
94
123
|
clear() {
|
|
95
124
|
this.data.id = "dve_air";
|
|
125
|
+
this.data.name = "";
|
|
96
126
|
this.data.secondaryVoxelId = "";
|
|
97
127
|
this.data.level = 0;
|
|
98
128
|
this.data.levelState = 0;
|
|
@@ -109,7 +139,7 @@ export class BrushTool {
|
|
|
109
139
|
const voxel = this.dataCursor.getVoxel(this.x, this.y, this.z);
|
|
110
140
|
if (!voxel)
|
|
111
141
|
return;
|
|
112
|
-
const id =
|
|
142
|
+
const id = VoxelPalettesRegister.voxels.getNumberId(this.data.id);
|
|
113
143
|
if (id < 0)
|
|
114
144
|
return false;
|
|
115
145
|
voxel.setId(id);
|
|
@@ -120,13 +150,14 @@ export class BrushTool {
|
|
|
120
150
|
voxel.setLevel(this.data.level);
|
|
121
151
|
voxel.setMod(this.data.mod);
|
|
122
152
|
if (this.data.secondaryVoxelId) {
|
|
123
|
-
const vid =
|
|
153
|
+
const vid = VoxelPalettesRegister.voxels.getNumberId(this.data.secondaryVoxelId);
|
|
124
154
|
if (vid > 0) {
|
|
125
155
|
voxel.setSecondary(true);
|
|
126
156
|
voxel.setId(vid);
|
|
127
157
|
voxel.setSecondary(false);
|
|
128
158
|
}
|
|
129
159
|
}
|
|
160
|
+
voxel.process();
|
|
130
161
|
if (voxel.isLightSource() && voxel.getLightSourceValue()) {
|
|
131
162
|
voxel.setLight(voxel.getLightSourceValue());
|
|
132
163
|
}
|
|
@@ -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,29 @@
|
|
|
1
|
+
export type BinaryBufferTypes =
|
|
2
|
+
/**If the buffer compressed to a single value the type will be a vlaue */
|
|
3
|
+
"value" | "1-bit" | "2-bit" | "4-bit" | "8-bit" | "16-bit";
|
|
4
|
+
export interface BinaryBufferData {
|
|
5
|
+
type?: BinaryBufferTypes;
|
|
6
|
+
buffer: number | Uint8Array | Uint16Array;
|
|
7
|
+
}
|
|
8
|
+
export interface BinaryBuffer extends BinaryBufferData {
|
|
9
|
+
}
|
|
10
|
+
export declare class BinaryBuffer {
|
|
11
|
+
static BytePaletteMax: number;
|
|
12
|
+
static NibblePaletteMax: number;
|
|
13
|
+
static HalfNibblePaletteMax: number;
|
|
14
|
+
static BitPaletteMax: number;
|
|
15
|
+
static DetermineSubByteArray: (paletteSize: number) => BinaryBufferTypes | null;
|
|
16
|
+
static CreateBufferForType(type: BinaryBufferTypes, length: number): Uint16Array | Uint8Array;
|
|
17
|
+
static GetConvertedBufferSize(source: Uint8Array | Uint16Array, type: BinaryBufferTypes): number;
|
|
18
|
+
static GetIndexLength(source: Uint8Array | Uint16Array, type: BinaryBufferTypes): number;
|
|
19
|
+
static ReadBufferAtIndex(source: Uint8Array | Uint16Array, type: BinaryBufferTypes, index: number): number;
|
|
20
|
+
static SetBufferAtIndex(source: Uint8Array | Uint16Array, type: BinaryBufferTypes, index: number, value: number): number | void;
|
|
21
|
+
static Convert(source: Uint8Array | Uint16Array, sourceType: BinaryBufferTypes, destinationType: BinaryBufferTypes): Uint16Array | Uint8Array;
|
|
22
|
+
static Create(data: Partial<BinaryBufferData>): BinaryBufferData;
|
|
23
|
+
constructor(data: BinaryBufferData);
|
|
24
|
+
getValue(index: number): number;
|
|
25
|
+
toJSON(): {
|
|
26
|
+
type?: BinaryBufferTypes | undefined;
|
|
27
|
+
buffer: number | Uint16Array | Uint8Array;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { getBitArrayIndex, getHalfNibbleArrayIndex, getNibbleArrayIndex, setBitArrayIndex, setHalfNibbleArrayIndex, setNibbleArrayIndex, } from "./BinaryArrays";
|
|
2
|
+
const excludeStore = ["16-bit", "8-bit", "value"];
|
|
3
|
+
export class BinaryBuffer {
|
|
4
|
+
static BytePaletteMax = 256;
|
|
5
|
+
static NibblePaletteMax = 16;
|
|
6
|
+
static HalfNibblePaletteMax = 4;
|
|
7
|
+
static BitPaletteMax = 2;
|
|
8
|
+
static DetermineSubByteArray = (paletteSize) => {
|
|
9
|
+
if (paletteSize == BinaryBuffer.BitPaletteMax)
|
|
10
|
+
return "1-bit";
|
|
11
|
+
if (paletteSize > BinaryBuffer.BitPaletteMax &&
|
|
12
|
+
paletteSize <= BinaryBuffer.HalfNibblePaletteMax)
|
|
13
|
+
return "2-bit";
|
|
14
|
+
if (paletteSize > BinaryBuffer.HalfNibblePaletteMax &&
|
|
15
|
+
paletteSize <= BinaryBuffer.NibblePaletteMax)
|
|
16
|
+
return "4-bit";
|
|
17
|
+
if (paletteSize > BinaryBuffer.NibblePaletteMax &&
|
|
18
|
+
paletteSize <= BinaryBuffer.BytePaletteMax)
|
|
19
|
+
return "8-bit";
|
|
20
|
+
return null;
|
|
21
|
+
};
|
|
22
|
+
static CreateBufferForType(type, length) {
|
|
23
|
+
if (type == "16-bit")
|
|
24
|
+
return new Uint16Array(length);
|
|
25
|
+
if (type == "8-bit")
|
|
26
|
+
return new Uint8Array(length);
|
|
27
|
+
if (type == "1-bit")
|
|
28
|
+
return new Uint8Array(length);
|
|
29
|
+
if (type == "2-bit")
|
|
30
|
+
return new Uint8Array(length);
|
|
31
|
+
if (type == "4-bit")
|
|
32
|
+
return new Uint8Array(length);
|
|
33
|
+
return new Uint8Array(length);
|
|
34
|
+
}
|
|
35
|
+
static GetConvertedBufferSize(source, type) {
|
|
36
|
+
if (type == "16-bit" || type == "8-bit")
|
|
37
|
+
return source.length;
|
|
38
|
+
if (type == "1-bit")
|
|
39
|
+
return source.length / 8;
|
|
40
|
+
if (type == "4-bit")
|
|
41
|
+
return source.length / 2;
|
|
42
|
+
if (type == "2-bit")
|
|
43
|
+
return source.length / 4;
|
|
44
|
+
if (type == "value")
|
|
45
|
+
return 1;
|
|
46
|
+
return source.length;
|
|
47
|
+
}
|
|
48
|
+
static GetIndexLength(source, type) {
|
|
49
|
+
if (type == "16-bit" || type == "8-bit")
|
|
50
|
+
return source.length;
|
|
51
|
+
if (type == "1-bit")
|
|
52
|
+
return source.length * 8;
|
|
53
|
+
if (type == "4-bit")
|
|
54
|
+
return source.length * 2;
|
|
55
|
+
if (type == "2-bit")
|
|
56
|
+
return source.length * 4;
|
|
57
|
+
if (type == "value")
|
|
58
|
+
return 1;
|
|
59
|
+
return source.length;
|
|
60
|
+
}
|
|
61
|
+
static ReadBufferAtIndex(source, type, index) {
|
|
62
|
+
if (type == "16-bit" || type == "8-bit")
|
|
63
|
+
return source[index];
|
|
64
|
+
if (type == "1-bit")
|
|
65
|
+
return getBitArrayIndex(source, index);
|
|
66
|
+
if (type == "4-bit")
|
|
67
|
+
return getNibbleArrayIndex(source, index);
|
|
68
|
+
if (type == "2-bit")
|
|
69
|
+
return getHalfNibbleArrayIndex(source, index);
|
|
70
|
+
return source[index];
|
|
71
|
+
}
|
|
72
|
+
static SetBufferAtIndex(source, type, index, value) {
|
|
73
|
+
if (type == "16-bit" || type == "8-bit") {
|
|
74
|
+
return (source[index] = value);
|
|
75
|
+
}
|
|
76
|
+
if (type == "1-bit")
|
|
77
|
+
return setBitArrayIndex(source, index, value);
|
|
78
|
+
if (type == "4-bit")
|
|
79
|
+
return setNibbleArrayIndex(source, index, value);
|
|
80
|
+
if (type == "2-bit")
|
|
81
|
+
return setHalfNibbleArrayIndex(source, index, value);
|
|
82
|
+
return source[index];
|
|
83
|
+
}
|
|
84
|
+
static Convert(source, sourceType, destinationType) {
|
|
85
|
+
if (sourceType == destinationType ||
|
|
86
|
+
(sourceType == "16-bit" && destinationType == "8-bit") ||
|
|
87
|
+
(sourceType == "8-bit" && destinationType == "16-bit")) {
|
|
88
|
+
const destination = this.CreateBufferForType(destinationType, this.GetConvertedBufferSize(source, destinationType));
|
|
89
|
+
destination.set(source);
|
|
90
|
+
return destination;
|
|
91
|
+
}
|
|
92
|
+
const length = this.GetIndexLength(source, sourceType);
|
|
93
|
+
const destination = this.CreateBufferForType(destinationType, this.GetConvertedBufferSize(source, destinationType));
|
|
94
|
+
for (let i = 0; i < length; i++) {
|
|
95
|
+
this.SetBufferAtIndex(destination, destinationType, i, this.ReadBufferAtIndex(source, sourceType, i));
|
|
96
|
+
}
|
|
97
|
+
return destination;
|
|
98
|
+
}
|
|
99
|
+
static Create(data) {
|
|
100
|
+
return {
|
|
101
|
+
buffer: 0,
|
|
102
|
+
...data,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
constructor(data) {
|
|
106
|
+
this.buffer = data.buffer;
|
|
107
|
+
if (data.type) {
|
|
108
|
+
this.type = data.type;
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
if (typeof data.buffer === "number")
|
|
112
|
+
this.type = "value";
|
|
113
|
+
if (data.buffer instanceof Uint16Array)
|
|
114
|
+
this.type = "16-bit";
|
|
115
|
+
if (data.buffer instanceof Uint8Array)
|
|
116
|
+
this.type = "8-bit";
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
getValue(index) {
|
|
120
|
+
if (typeof this.buffer == "number")
|
|
121
|
+
return this.buffer;
|
|
122
|
+
return BinaryBuffer.ReadBufferAtIndex(this.buffer, this.type, index);
|
|
123
|
+
}
|
|
124
|
+
toJSON() {
|
|
125
|
+
return {
|
|
126
|
+
buffer: this.buffer,
|
|
127
|
+
...(excludeStore.includes(this.type) ? {} : { type: this.type }),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
}
|
|
@@ -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
|
+
}
|
package/Util/StringPalette.d.ts
CHANGED
package/Util/StringPalette.js
CHANGED
|
@@ -13,6 +13,14 @@ export class StringPalette {
|
|
|
13
13
|
get size() {
|
|
14
14
|
return this._count;
|
|
15
15
|
}
|
|
16
|
+
load(palette) {
|
|
17
|
+
this._palette = [];
|
|
18
|
+
this._map = {};
|
|
19
|
+
const length = palette.length;
|
|
20
|
+
for (let i = 0; i < length; i++) {
|
|
21
|
+
this.register(palette[i]);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
16
24
|
register(string) {
|
|
17
25
|
const id = this._count;
|
|
18
26
|
this._count++;
|
|
@@ -2,12 +2,12 @@ import { VoxelCursorInterface } from "./VoxelCursor.interface";
|
|
|
2
2
|
import { PaintVoxelData, RawVoxelData } from "../Types/Voxel.types";
|
|
3
3
|
export declare class VoxelCursor extends VoxelCursorInterface {
|
|
4
4
|
static VoxelDataToRaw(data: Partial<PaintVoxelData>, light?: number): RawVoxelData;
|
|
5
|
-
ids:
|
|
6
|
-
light:
|
|
7
|
-
level:
|
|
8
|
-
state:
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
ids: Uint16Array;
|
|
6
|
+
light: Uint16Array;
|
|
7
|
+
level: Uint8Array;
|
|
8
|
+
state: Uint16Array;
|
|
9
|
+
mod: Uint16Array;
|
|
10
|
+
secondary: Uint16Array;
|
|
11
11
|
loadIn(): void;
|
|
12
12
|
updateVoxel(mode: 0 | 1): void;
|
|
13
13
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { VoxelLightData } from "./VoxelLightData";
|
|
2
|
-
import { VoxelStruct } from "../Structs/VoxelStruct";
|
|
3
2
|
import { RawVoxelData } from "../Types/Voxel.types";
|
|
4
|
-
import {
|
|
3
|
+
import { VoxelSubstanceTags, VoxelTags } from "../../Voxels/Data/VoxelTag.types";
|
|
5
4
|
interface WritableArrayLike<T> {
|
|
6
5
|
length: number;
|
|
7
6
|
[index: number]: T;
|
|
@@ -10,7 +9,8 @@ export declare abstract class VoxelCursorInterface {
|
|
|
10
9
|
_loadedId: number;
|
|
11
10
|
id: number;
|
|
12
11
|
secondaryId: number;
|
|
13
|
-
|
|
12
|
+
_tags: VoxelTags;
|
|
13
|
+
_substanceTags: VoxelSubstanceTags;
|
|
14
14
|
__secondary: boolean;
|
|
15
15
|
_index: number;
|
|
16
16
|
abstract ids: WritableArrayLike<number>;
|
|
@@ -21,24 +21,19 @@ export declare abstract class VoxelCursorInterface {
|
|
|
21
21
|
abstract mod: WritableArrayLike<number>;
|
|
22
22
|
/**
|
|
23
23
|
*
|
|
24
|
-
* @param mode 0 for add 1 for remove
|
|
24
|
+
* @param mode 0 for add 1 for remove 2 for the voxel needs a buried check only
|
|
25
25
|
*/
|
|
26
|
-
abstract updateVoxel(mode: 0 | 1): void;
|
|
26
|
+
abstract updateVoxel(mode: 0 | 1 | 2): void;
|
|
27
27
|
_lightData: VoxelLightData;
|
|
28
|
-
_substanceData: SubstanceDataTool;
|
|
29
28
|
process(): void;
|
|
30
29
|
abstract loadIn(): void;
|
|
31
30
|
setSecondary(enable: boolean): this;
|
|
32
|
-
getRenderedMaterial():
|
|
33
|
-
|
|
34
|
-
getMaterial(): number;
|
|
35
|
-
getMaterialStringId(): string;
|
|
31
|
+
getRenderedMaterial(): string;
|
|
32
|
+
getMaterial(): string;
|
|
36
33
|
checkCollisions(): boolean;
|
|
37
|
-
getCollider():
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
getSubstanceData(): SubstanceDataTool;
|
|
41
|
-
getSubstanceStringId(): string;
|
|
34
|
+
getCollider(): string;
|
|
35
|
+
getSubstance(): string;
|
|
36
|
+
getSubstanceData(): VoxelSubstanceTags;
|
|
42
37
|
isOpaque(): boolean;
|
|
43
38
|
getMod(): number;
|
|
44
39
|
setMod(mod: number): this;
|
|
@@ -64,7 +59,7 @@ export declare abstract class VoxelCursorInterface {
|
|
|
64
59
|
setId(id: number): this;
|
|
65
60
|
setStringId(id: string): this;
|
|
66
61
|
getStringId(): string;
|
|
67
|
-
setName(name: string):
|
|
62
|
+
setName(name: string): this;
|
|
68
63
|
getName(): string;
|
|
69
64
|
isSameVoxel(voxel: VoxelCursorInterface): boolean;
|
|
70
65
|
copy(cursor: VoxelCursorInterface): this;
|
|
@@ -1,26 +1,20 @@
|
|
|
1
|
-
import { VoxelStructIds } from "../Types/Voxel.types";
|
|
2
1
|
import { VoxelLightData } from "./VoxelLightData";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { SubstancePalette } from "../Palettes/SubstancePalette";
|
|
9
|
-
import { MaterialPalette } from "../Palettes/MaterialPalette";
|
|
10
|
-
import { SubstanceDataTool } from "../../Tools/Data/SubstanceDataTool";
|
|
2
|
+
import { VoxelLevelReader } from "./VoxelLevelReader";
|
|
3
|
+
import { VoxelTagStates } from "../Data/VoxelTagStates";
|
|
4
|
+
import { VoxelTagIds, } from "../../Voxels/Data/VoxelTag.types";
|
|
5
|
+
import { VoxelTagsRegister } from "../../Voxels/Data/VoxelTagsRegister";
|
|
6
|
+
import { VoxelPalettesRegister } from "../../Voxels/Data/VoxelPalettesRegister";
|
|
11
7
|
export class VoxelCursorInterface {
|
|
12
8
|
_loadedId = 0;
|
|
13
9
|
id = 0;
|
|
14
10
|
secondaryId = 0;
|
|
15
|
-
|
|
11
|
+
_tags;
|
|
12
|
+
_substanceTags;
|
|
16
13
|
__secondary = false;
|
|
17
14
|
// private _section: Section;
|
|
18
15
|
_index = 0;
|
|
19
16
|
_lightData = new VoxelLightData();
|
|
20
|
-
_substanceData = new SubstanceDataTool();
|
|
21
17
|
process() {
|
|
22
|
-
if (!this.__struct)
|
|
23
|
-
this.__struct = VoxelStruct.clone();
|
|
24
18
|
this.id = this.ids[this._index];
|
|
25
19
|
this.secondaryId = this.secondary[this._index];
|
|
26
20
|
if (this.secondaryId > 1) {
|
|
@@ -29,52 +23,38 @@ export class VoxelCursorInterface {
|
|
|
29
23
|
else {
|
|
30
24
|
this.secondaryId = 0;
|
|
31
25
|
}
|
|
32
|
-
this.__struct.setIndex(VoxelStruct.voxelIndex[this.id]);
|
|
33
26
|
this._loadedId = this.getId();
|
|
27
|
+
this._tags = VoxelTagsRegister.VoxelTags[this._loadedId];
|
|
28
|
+
this._substanceTags =
|
|
29
|
+
VoxelTagsRegister.SubstanceStags[VoxelPalettesRegister.substance.getNumberId(this._tags["dve_substance"])];
|
|
34
30
|
}
|
|
35
31
|
setSecondary(enable) {
|
|
36
32
|
this.__secondary = enable;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
this.__struct.setIndex(VoxelStruct.voxelIndex[this.id]);
|
|
42
|
-
}
|
|
33
|
+
VoxelTagIds;
|
|
34
|
+
VoxelTagsRegister;
|
|
43
35
|
this._loadedId = this.getId();
|
|
44
36
|
return this;
|
|
45
37
|
}
|
|
46
38
|
getRenderedMaterial() {
|
|
47
|
-
return this.
|
|
48
|
-
}
|
|
49
|
-
getRenderedMaterialStringId() {
|
|
50
|
-
return MaterialPalette.id.stringFromNumber(this.__struct[VoxelStructIds.renderedMaterial]);
|
|
39
|
+
return this._tags[VoxelTagIds.renderedMaterial];
|
|
51
40
|
}
|
|
52
41
|
getMaterial() {
|
|
53
|
-
return this.
|
|
54
|
-
}
|
|
55
|
-
getMaterialStringId() {
|
|
56
|
-
return MaterialPalette.id.stringFromNumber(this.__struct[VoxelStructIds.voxelMaterial]);
|
|
42
|
+
return this._tags[VoxelTagIds.voxelMaterial];
|
|
57
43
|
}
|
|
58
44
|
checkCollisions() {
|
|
59
|
-
return this.
|
|
45
|
+
return this._tags[VoxelTagIds.checkCollisions];
|
|
60
46
|
}
|
|
61
47
|
getCollider() {
|
|
62
|
-
return this.
|
|
63
|
-
}
|
|
64
|
-
getColliderStringId() {
|
|
65
|
-
return MappedDataRegister.stringMaps.get("voxel", VoxelStructIds.colliderID, this.__struct[VoxelStructIds.colliderID]);
|
|
48
|
+
return this._tags[VoxelTagIds.colliderID];
|
|
66
49
|
}
|
|
67
50
|
getSubstance() {
|
|
68
|
-
return this.
|
|
51
|
+
return this._tags[VoxelTagIds.substance];
|
|
69
52
|
}
|
|
70
53
|
getSubstanceData() {
|
|
71
|
-
return this.
|
|
72
|
-
}
|
|
73
|
-
getSubstanceStringId() {
|
|
74
|
-
return SubstancePalette.id.stringFromNumber(this.getSubstance());
|
|
54
|
+
return this._substanceTags;
|
|
75
55
|
}
|
|
76
56
|
isOpaque() {
|
|
77
|
-
return this.
|
|
57
|
+
return !this._tags[VoxelTagIds.isTransparent];
|
|
78
58
|
}
|
|
79
59
|
getMod() {
|
|
80
60
|
return this.mod[this._index];
|
|
@@ -108,7 +88,7 @@ export class VoxelCursorInterface {
|
|
|
108
88
|
return this.secondaryId > 1;
|
|
109
89
|
}
|
|
110
90
|
canHaveSecondaryVoxel() {
|
|
111
|
-
return this.
|
|
91
|
+
return this._tags[VoxelTagIds.canHaveSecondary];
|
|
112
92
|
}
|
|
113
93
|
hasRGBLight() {
|
|
114
94
|
const light = this.getLight();
|
|
@@ -125,17 +105,14 @@ export class VoxelCursorInterface {
|
|
|
125
105
|
getLight() {
|
|
126
106
|
if (this._loadedId == 0)
|
|
127
107
|
return this.light[this._index];
|
|
128
|
-
const lightValue = this.__struct[VoxelStructIds.lightValue];
|
|
129
108
|
if (this.isOpaque()) {
|
|
130
|
-
if (this.isLightSource()
|
|
131
|
-
return lightValue;
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
return -1;
|
|
109
|
+
if (this.isLightSource()) {
|
|
110
|
+
return this._tags[VoxelTagIds.lightValue];
|
|
135
111
|
}
|
|
112
|
+
return -1;
|
|
136
113
|
}
|
|
137
|
-
if (this.isLightSource()
|
|
138
|
-
return this._lightData.mixLight(this.light[this._index], lightValue);
|
|
114
|
+
if (this.isLightSource()) {
|
|
115
|
+
return this._lightData.mixLight(this.light[this._index], this._tags[VoxelTagIds.lightValue]);
|
|
139
116
|
}
|
|
140
117
|
return this.light[this._index];
|
|
141
118
|
}
|
|
@@ -146,19 +123,19 @@ export class VoxelCursorInterface {
|
|
|
146
123
|
isLightSource() {
|
|
147
124
|
if (this._loadedId <= 0)
|
|
148
125
|
return false;
|
|
149
|
-
return VoxelTagStates.isRegistered(this._loadedId,
|
|
150
|
-
? VoxelTagStates.getValue(this._loadedId,
|
|
151
|
-
: this.
|
|
126
|
+
return VoxelTagStates.isRegistered(this._loadedId, VoxelTagIds.isLightSource)
|
|
127
|
+
? VoxelTagStates.getValue(this._loadedId, VoxelTagIds.isLightSource, this.getState()) === true
|
|
128
|
+
: this._tags[VoxelTagIds.isLightSource];
|
|
152
129
|
}
|
|
153
130
|
getLightSourceValue() {
|
|
154
131
|
if (this._loadedId <= 0)
|
|
155
132
|
return 0;
|
|
156
|
-
return this.
|
|
133
|
+
return this._tags[VoxelTagIds.lightValue];
|
|
157
134
|
}
|
|
158
135
|
noAO() {
|
|
159
136
|
if (this._loadedId <= 0)
|
|
160
137
|
return false;
|
|
161
|
-
return this.
|
|
138
|
+
return this._tags[VoxelTagIds.noAO];
|
|
162
139
|
}
|
|
163
140
|
isRenderable() {
|
|
164
141
|
if (this.id > 0)
|
|
@@ -189,19 +166,19 @@ export class VoxelCursorInterface {
|
|
|
189
166
|
return this;
|
|
190
167
|
}
|
|
191
168
|
setStringId(id) {
|
|
192
|
-
return this.setId(
|
|
169
|
+
return this.setId(VoxelPalettesRegister.voxels.getNumberId(id));
|
|
193
170
|
}
|
|
194
171
|
getStringId() {
|
|
195
172
|
if (this.__secondary) {
|
|
196
|
-
return
|
|
173
|
+
return VoxelPalettesRegister.voxels.getStringId(this.secondaryId);
|
|
197
174
|
}
|
|
198
|
-
return
|
|
175
|
+
return VoxelPalettesRegister.voxels.getStringId(this.id);
|
|
199
176
|
}
|
|
200
177
|
setName(name) {
|
|
201
|
-
this.setStringId(
|
|
178
|
+
return this.setStringId(VoxelPalettesRegister.voxelNametoIdMap.get(name));
|
|
202
179
|
}
|
|
203
180
|
getName() {
|
|
204
|
-
return this.getStringId();
|
|
181
|
+
return VoxelPalettesRegister.voxelIdToNameMap.get(this.getStringId());
|
|
205
182
|
}
|
|
206
183
|
isSameVoxel(voxel) {
|
|
207
184
|
return this.getId() == voxel.getId();
|