@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
|
@@ -4,7 +4,6 @@ import { getInterpolationValue, shouldCauseFlip, } from "../../Common/Calc/CalcC
|
|
|
4
4
|
import { QuadVoxelGometryInputs, } from "../../../../Models/Input/QuadVoxelGometryInputs";
|
|
5
5
|
import { GeoemtryNode } from "../GeometryNode";
|
|
6
6
|
import { GetQuadGeometryData } from "../../Common/QuadGeometryNode";
|
|
7
|
-
import { UpdateBounds } from "../../Common/BoundsFunctions";
|
|
8
7
|
import { VoxelLightData } from "../../../../Voxels/Cursor/VoxelLightData";
|
|
9
8
|
const ArgIndexes = QuadVoxelGometryInputs.ArgIndexes;
|
|
10
9
|
export class RulelessQuadVoxelGeometryNode extends GeoemtryNode {
|
|
@@ -14,8 +13,6 @@ export class RulelessQuadVoxelGeometryNode extends GeoemtryNode {
|
|
|
14
13
|
[0, 0, 0],
|
|
15
14
|
];
|
|
16
15
|
vertexWeights;
|
|
17
|
-
worldLight;
|
|
18
|
-
worldAO;
|
|
19
16
|
closestFace;
|
|
20
17
|
lightData = new VoxelLightData();
|
|
21
18
|
init() {
|
|
@@ -28,11 +25,11 @@ export class RulelessQuadVoxelGeometryNode extends GeoemtryNode {
|
|
|
28
25
|
this.closestFace = closestFace;
|
|
29
26
|
}
|
|
30
27
|
determineShading() {
|
|
31
|
-
const tool = this.
|
|
28
|
+
const tool = this.builder;
|
|
32
29
|
const lightData = tool.lightData[VoxelFaces.Up];
|
|
33
|
-
const noAO = this.
|
|
34
|
-
const worldLight = this.
|
|
35
|
-
const worldAO = this.
|
|
30
|
+
const noAO = this.builder.voxel.isLightSource() || this.builder.voxel.noAO();
|
|
31
|
+
const worldLight = this.builder.vars.light;
|
|
32
|
+
const worldAO = this.builder.vars.ao;
|
|
36
33
|
for (let v = 0; v < 4; v++) {
|
|
37
34
|
worldAO.vertices[v] = 0;
|
|
38
35
|
worldLight.vertices[v] = getInterpolationValue(lightData, this.vertexWeights[v]);
|
|
@@ -41,40 +38,40 @@ export class RulelessQuadVoxelGeometryNode extends GeoemtryNode {
|
|
|
41
38
|
}
|
|
42
39
|
}
|
|
43
40
|
shouldFlip() {
|
|
44
|
-
|
|
41
|
+
const worldLight = this.builder.vars.light;
|
|
42
|
+
const worldAO = this.builder.vars.ao;
|
|
43
|
+
if (shouldCauseFlip(worldAO.vertices[0], worldAO.vertices[1], worldAO.vertices[2], worldAO.vertices[3]))
|
|
45
44
|
return true;
|
|
46
|
-
return (shouldCauseFlip(this.lightData.getS(
|
|
47
|
-
shouldCauseFlip(this.lightData.sumRGB(
|
|
45
|
+
return (shouldCauseFlip(this.lightData.getS(worldLight.vertices[0]), this.lightData.getS(worldLight.vertices[1]), this.lightData.getS(worldLight.vertices[2]), this.lightData.getS(worldLight.vertices[3])) ||
|
|
46
|
+
shouldCauseFlip(this.lightData.sumRGB(worldLight.vertices[0]), this.lightData.sumRGB(worldLight.vertices[1]), this.lightData.sumRGB(worldLight.vertices[2]), this.lightData.sumRGB(worldLight.vertices[3])));
|
|
48
47
|
}
|
|
49
|
-
add(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
this.worldLight.setAll(0);
|
|
78
|
-
this.worldAO.setAll(0);
|
|
48
|
+
add(args) {
|
|
49
|
+
if (!args[ArgIndexes.Enabled])
|
|
50
|
+
return false;
|
|
51
|
+
const tool = this.builder;
|
|
52
|
+
tool.calculateFaceData(this.closestFace);
|
|
53
|
+
this.determineShading();
|
|
54
|
+
const quad = this.quad;
|
|
55
|
+
quad.flip = this.shouldFlip() || args[ArgIndexes.Fliped];
|
|
56
|
+
tool.vars.textureIndex = args[ArgIndexes.Texture];
|
|
57
|
+
quad.doubleSided = args[ArgIndexes.DoubleSided];
|
|
58
|
+
const uvs = args[ArgIndexes.UVs];
|
|
59
|
+
//1
|
|
60
|
+
quad.uvs.vertices[0].x = uvs[0][0];
|
|
61
|
+
quad.uvs.vertices[0].y = uvs[0][1];
|
|
62
|
+
//2
|
|
63
|
+
quad.uvs.vertices[1].x = uvs[1][0];
|
|
64
|
+
quad.uvs.vertices[1].y = uvs[1][1];
|
|
65
|
+
//3
|
|
66
|
+
quad.uvs.vertices[2].x = uvs[2][0];
|
|
67
|
+
quad.uvs.vertices[2].y = uvs[2][1];
|
|
68
|
+
//4
|
|
69
|
+
quad.uvs.vertices[3].x = uvs[3][0];
|
|
70
|
+
quad.uvs.vertices[3].y = uvs[3][1];
|
|
71
|
+
VoxelGeometryBuilder.addQuad(tool, tool.position, quad);
|
|
72
|
+
this.builder.updateBounds(this.quadBounds);
|
|
73
|
+
this.builder.vars.light.setAll(0);
|
|
74
|
+
this.builder.vars.ao.setAll(0);
|
|
75
|
+
return true;
|
|
79
76
|
}
|
|
80
77
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { VoxelModelBuilder } from "./VoxelModelBuilder";
|
|
2
2
|
export class RenderedMaterials {
|
|
3
3
|
static meshersMap = new Map();
|
|
4
4
|
static meshers = [];
|
|
5
5
|
static register(materials) {
|
|
6
6
|
for (let i = 0; i < materials.length; i++) {
|
|
7
|
-
const newTool = new
|
|
7
|
+
const newTool = new VoxelModelBuilder(materials[i], i);
|
|
8
8
|
this.meshersMap.set(materials[i], newTool);
|
|
9
9
|
this.meshers[i] = newTool;
|
|
10
10
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { VoxelMesherDataTool } from "../../Mesher/Tools/VoxelMesherDataTool";
|
|
1
|
+
import { VoxelModelBuilder } from "./VoxelModelBuilder";
|
|
3
2
|
import { CompiledVoxelModelInputData, CompiledVoxelModelData } from "../../Voxels/Types/VoxelModelCompiledData.types";
|
|
4
3
|
import { StateSchema } from "../../Voxels/State/Schema/StateSchema";
|
|
5
4
|
import { StateTreeReader } from "../../Voxels/State/StateTreeReader";
|
|
@@ -8,6 +7,7 @@ import { VoxelModelEffect } from "./VoxelModelEffect";
|
|
|
8
7
|
import { CondtionalTreeReader } from "../../Voxels/State/CondiotnalTreeReader";
|
|
9
8
|
export declare class VoxelConstructor {
|
|
10
9
|
id: string;
|
|
10
|
+
builder: VoxelModelBuilder;
|
|
11
11
|
data: CompiledVoxelModelData;
|
|
12
12
|
isModel: true;
|
|
13
13
|
geometries: number[][];
|
|
@@ -20,9 +20,8 @@ export declare class VoxelConstructor {
|
|
|
20
20
|
effects: VoxelModelEffect;
|
|
21
21
|
shapeStateTree: StateTreeReader;
|
|
22
22
|
condtioanlShapeStateTree: CondtionalTreeReader;
|
|
23
|
-
constructor(id: string, data: CompiledVoxelModelData, voxleData: CompiledVoxelModelInputData);
|
|
23
|
+
constructor(id: string, builder: VoxelModelBuilder, data: CompiledVoxelModelData, voxleData: CompiledVoxelModelInputData);
|
|
24
24
|
isShapeStateFaceTransparent(modState: number, shapeState: number, geoId: number, faceIndex: number): boolean;
|
|
25
25
|
isCondtionalStateFaceTransparent(modState: number, shapeState: number, geoId: number, faceIndex: number): boolean;
|
|
26
|
-
process(
|
|
27
|
-
onTexturesRegistered(textureManager: typeof TextureRegister): void;
|
|
26
|
+
process(): boolean;
|
|
28
27
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { VoxelModelConstructorRegister } from "./VoxelModelConstructorRegister";
|
|
2
|
-
import { VoxelGeometryLookUp } from "./VoxelGeometryLookUp";
|
|
3
2
|
import { StateSchema } from "../../Voxels/State/Schema/StateSchema";
|
|
4
3
|
import { StateTreeReader } from "../../Voxels/State/StateTreeReader";
|
|
5
4
|
import { VoxelFaceTransparentResultsIndex } from "../../Models/Indexing/VoxelFaceTransparentResultsIndex";
|
|
@@ -7,6 +6,7 @@ import { VoxelModelEffect } from "./VoxelModelEffect";
|
|
|
7
6
|
import { CondtionalTreeReader } from "../../Voxels/State/CondiotnalTreeReader";
|
|
8
7
|
export class VoxelConstructor {
|
|
9
8
|
id;
|
|
9
|
+
builder;
|
|
10
10
|
data;
|
|
11
11
|
isModel = true;
|
|
12
12
|
geometries = [];
|
|
@@ -19,8 +19,9 @@ export class VoxelConstructor {
|
|
|
19
19
|
effects;
|
|
20
20
|
shapeStateTree;
|
|
21
21
|
condtioanlShapeStateTree;
|
|
22
|
-
constructor(id, data, voxleData) {
|
|
22
|
+
constructor(id, builder, data, voxleData) {
|
|
23
23
|
this.id = id;
|
|
24
|
+
this.builder = builder;
|
|
24
25
|
this.data = data;
|
|
25
26
|
this.baseInputMap = voxleData.baseGeometryInputMap;
|
|
26
27
|
this.conditonalInputMap = voxleData.condiotnalGeometryInputMap;
|
|
@@ -38,10 +39,12 @@ export class VoxelConstructor {
|
|
|
38
39
|
isCondtionalStateFaceTransparent(modState, shapeState, geoId, faceIndex) {
|
|
39
40
|
return (this.transparentIndex.getValue(modState, this.data.relativeGeometryByteIndexMap[this.data.condiotnalShapeStateRelativeGeometryMap[shapeState][geoId]], faceIndex) == 1);
|
|
40
41
|
}
|
|
41
|
-
process(
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
const
|
|
42
|
+
process() {
|
|
43
|
+
let added = false;
|
|
44
|
+
const builder = this.builder;
|
|
45
|
+
const hashed = builder.space.getHash(builder.nVoxel, builder.position.x, builder.position.y, builder.position.z);
|
|
46
|
+
const treeState = builder.space.stateCache[hashed];
|
|
47
|
+
const modState = builder.space.modCache[hashed];
|
|
45
48
|
if (treeState > -1) {
|
|
46
49
|
const geoLinks = this.data.shapeStateMap[treeState];
|
|
47
50
|
const geometries = this.data.shapeStateGeometryMap[treeState];
|
|
@@ -53,11 +56,15 @@ export class VoxelConstructor {
|
|
|
53
56
|
const geomtry = VoxelModelConstructorRegister.geometry[geometries[i]];
|
|
54
57
|
const nodesLength = geomtry.nodes.length;
|
|
55
58
|
for (let k = 0; k < nodesLength; k++) {
|
|
56
|
-
geomtry.nodes[k]
|
|
59
|
+
const geo = geomtry.nodes[k];
|
|
60
|
+
geo.builder = this.builder;
|
|
61
|
+
const addedGeo = geo.add(geoInputs[k]);
|
|
62
|
+
if (addedGeo)
|
|
63
|
+
added = true;
|
|
57
64
|
}
|
|
58
65
|
}
|
|
59
66
|
}
|
|
60
|
-
const conditonalTreeState =
|
|
67
|
+
const conditonalTreeState = builder.space.conditonalStateCache[hashed];
|
|
61
68
|
if (conditonalTreeState > -1) {
|
|
62
69
|
const condiotnalNodes = this.data.condiotnalShapeStateMap[conditonalTreeState];
|
|
63
70
|
const condiotnalNodesLength = condiotnalNodes.length;
|
|
@@ -71,13 +78,17 @@ export class VoxelConstructor {
|
|
|
71
78
|
const geomtry = VoxelModelConstructorRegister.geometry[this.data.geoLinkMap[nodeId]];
|
|
72
79
|
const nodesLength = geomtry.nodes.length;
|
|
73
80
|
for (let k = 0; k < nodesLength; k++) {
|
|
74
|
-
geomtry.nodes[k]
|
|
81
|
+
const geo = geomtry.nodes[k];
|
|
82
|
+
geo.builder = this.builder;
|
|
83
|
+
const addedGeo = geo.add(geoInputs[k]);
|
|
84
|
+
if (addedGeo)
|
|
85
|
+
added = true;
|
|
75
86
|
}
|
|
76
87
|
}
|
|
77
88
|
}
|
|
78
89
|
}
|
|
79
|
-
this.effects.addEffects(
|
|
80
|
-
|
|
90
|
+
this.effects.addEffects(builder.voxel.getState(), builder.origin, builder.effects);
|
|
91
|
+
builder.clearCalculatedData();
|
|
92
|
+
return added;
|
|
81
93
|
}
|
|
82
|
-
onTexturesRegistered(textureManager) { }
|
|
83
94
|
}
|
|
@@ -1,30 +1,22 @@
|
|
|
1
|
-
import { DataCursorInterface } from "../../
|
|
1
|
+
import { DataCursorInterface } from "../../Voxels/Cursor/DataCursor.interface";
|
|
2
2
|
import { Vec3Array, Vector3Like } from "@amodx/math";
|
|
3
3
|
import { VoxelCursor } from "../../Voxels/Cursor/VoxelCursor";
|
|
4
|
-
export declare class
|
|
4
|
+
export declare class VoxelGeometryBuilderCacheSpace {
|
|
5
5
|
bounds: Vector3Like;
|
|
6
6
|
foundHash: Uint8Array;
|
|
7
|
-
|
|
7
|
+
voxelCache: Uint16Array;
|
|
8
8
|
modCache: Int32Array;
|
|
9
9
|
stateCache: Int32Array;
|
|
10
10
|
conditonalStateCache: Int32Array;
|
|
11
11
|
noCastAO: Uint8Array;
|
|
12
12
|
offset: Vec3Array;
|
|
13
|
+
voxelCursor: VoxelCursor;
|
|
13
14
|
constructor(bounds: Vector3Like);
|
|
14
15
|
start(x: number, y: number, z: number): void;
|
|
15
16
|
getIndex(x: number, y: number, z: number): number;
|
|
16
17
|
getConstructor(index: number): import("./VoxelConstructor").VoxelConstructor | null;
|
|
17
18
|
getGeomtry(index: number): false | number[];
|
|
18
19
|
getConditionalGeomtry(index: number): false | number[][];
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
static space: VoxelGeometryLookUpSpace | null;
|
|
22
|
-
static voxelCursor: VoxelCursor;
|
|
23
|
-
static createSpace(x: number, y: number, z: number): VoxelGeometryLookUpSpace;
|
|
24
|
-
static init(): void;
|
|
25
|
-
static start(space: VoxelGeometryLookUpSpace): void;
|
|
26
|
-
static isRulesless(geoId: number): boolean;
|
|
27
|
-
static stop(): void;
|
|
28
|
-
static getHash(dataCursor: DataCursorInterface, x: number, y: number, z: number): number;
|
|
29
|
-
private static hashState;
|
|
20
|
+
getHash(dataCursor: DataCursorInterface, x: number, y: number, z: number): number;
|
|
21
|
+
private hashState;
|
|
30
22
|
}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { VoxelModelConstructorRegister } from "./VoxelModelConstructorRegister";
|
|
2
2
|
import { VoxelCursor } from "../../Voxels/Cursor/VoxelCursor";
|
|
3
3
|
import { GetYXZOrderArrayIndex } from "../../Math/Indexing";
|
|
4
|
-
export class
|
|
4
|
+
export class VoxelGeometryBuilderCacheSpace {
|
|
5
5
|
bounds;
|
|
6
6
|
foundHash;
|
|
7
|
-
|
|
7
|
+
voxelCache;
|
|
8
8
|
modCache;
|
|
9
9
|
stateCache;
|
|
10
10
|
conditonalStateCache;
|
|
11
11
|
noCastAO;
|
|
12
12
|
offset = [0, 0, 0];
|
|
13
|
+
voxelCursor = new VoxelCursor();
|
|
13
14
|
constructor(bounds) {
|
|
14
15
|
this.bounds = bounds;
|
|
15
16
|
const volume = bounds.x * bounds.y * bounds.z;
|
|
16
17
|
this.foundHash = new Uint8Array(volume);
|
|
17
|
-
this.
|
|
18
|
+
this.voxelCache = new Uint16Array(volume);
|
|
18
19
|
this.modCache = new Int32Array(volume);
|
|
19
20
|
this.stateCache = new Int32Array(volume);
|
|
20
21
|
this.conditonalStateCache = new Int32Array(volume);
|
|
@@ -25,7 +26,7 @@ export class VoxelGeometryLookUpSpace {
|
|
|
25
26
|
this.offset[1] = y;
|
|
26
27
|
this.offset[2] = z;
|
|
27
28
|
this.foundHash.fill(0);
|
|
28
|
-
this.
|
|
29
|
+
this.voxelCache.fill(0);
|
|
29
30
|
this.modCache.fill(-1);
|
|
30
31
|
this.stateCache.fill(-1);
|
|
31
32
|
this.conditonalStateCache.fill(-1);
|
|
@@ -35,72 +36,53 @@ export class VoxelGeometryLookUpSpace {
|
|
|
35
36
|
return GetYXZOrderArrayIndex(x - this.offset[0], y - this.offset[1], z - this.offset[2], this.bounds.x, this.bounds.y, this.bounds.z);
|
|
36
37
|
}
|
|
37
38
|
getConstructor(index) {
|
|
38
|
-
if (this.foundHash[index]
|
|
39
|
+
if (this.foundHash[index] < 2)
|
|
39
40
|
return null;
|
|
40
|
-
return VoxelModelConstructorRegister.constructorsPaltte[this.
|
|
41
|
+
return VoxelModelConstructorRegister.constructorsPaltte[this.voxelCache[index]];
|
|
41
42
|
}
|
|
42
43
|
getGeomtry(index) {
|
|
43
|
-
if (this.foundHash[index]
|
|
44
|
+
if (this.foundHash[index] < 2)
|
|
44
45
|
return false;
|
|
45
|
-
return VoxelModelConstructorRegister.constructorsPaltte[this.
|
|
46
|
+
return VoxelModelConstructorRegister.constructorsPaltte[this.voxelCache[index]].data.shapeStateGeometryMap[this.stateCache[index]];
|
|
46
47
|
}
|
|
47
48
|
getConditionalGeomtry(index) {
|
|
48
|
-
if (this.foundHash[index]
|
|
49
|
+
if (this.foundHash[index] < 2)
|
|
49
50
|
return false;
|
|
50
|
-
return VoxelModelConstructorRegister.constructorsPaltte[this.
|
|
51
|
+
return VoxelModelConstructorRegister.constructorsPaltte[this.voxelCache[index]].data.condiotnalShapeStateGeometryMap[this.conditonalStateCache[index]];
|
|
51
52
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
static voxelCursor = new VoxelCursor();
|
|
56
|
-
static createSpace(x, y, z) {
|
|
57
|
-
return new VoxelGeometryLookUpSpace({ x, y, z });
|
|
58
|
-
}
|
|
59
|
-
static init() { }
|
|
60
|
-
static start(space) {
|
|
61
|
-
this.space = space;
|
|
62
|
-
}
|
|
63
|
-
static isRulesless(geoId) {
|
|
64
|
-
return VoxelModelConstructorRegister.rulesless[geoId] == true;
|
|
65
|
-
}
|
|
66
|
-
static stop() { }
|
|
67
|
-
static getHash(dataCursor, x, y, z) {
|
|
68
|
-
if (!this.space)
|
|
69
|
-
throw new Error(`Voxel geomtry look up must have space set`);
|
|
70
|
-
const hashed = this.space.getIndex(x, y, z);
|
|
71
|
-
if (this.space.foundHash[hashed] == 0) {
|
|
53
|
+
getHash(dataCursor, x, y, z) {
|
|
54
|
+
const hashed = this.getIndex(x, y, z);
|
|
55
|
+
if (this.foundHash[hashed] == 0) {
|
|
72
56
|
this.hashState(dataCursor, hashed, x, y, z);
|
|
73
57
|
}
|
|
74
58
|
return hashed;
|
|
75
59
|
}
|
|
76
|
-
|
|
77
|
-
if (
|
|
78
|
-
throw new Error(`Voxel geomtry look up must have space set`);
|
|
79
|
-
if (this.space.foundHash[index] == 1)
|
|
60
|
+
hashState(dataCursor, index, x, y, z) {
|
|
61
|
+
if (this.foundHash[index] == 1)
|
|
80
62
|
return -1;
|
|
81
|
-
if (this.
|
|
82
|
-
return this.
|
|
63
|
+
if (this.foundHash[index] == 2)
|
|
64
|
+
return this.stateCache[index];
|
|
83
65
|
const voxel = dataCursor.getVoxel(x, y, z);
|
|
84
66
|
if (!voxel || !voxel.isRenderable()) {
|
|
85
|
-
this.
|
|
67
|
+
this.foundHash[index] = 1;
|
|
86
68
|
return -1;
|
|
87
69
|
}
|
|
88
70
|
const voxelId = voxel.getId();
|
|
89
71
|
const voxelConstructor = VoxelModelConstructorRegister.constructorsPaltte[voxelId];
|
|
90
72
|
if (!voxelConstructor) {
|
|
91
|
-
this.
|
|
73
|
+
this.foundHash[index] = 1;
|
|
92
74
|
return -1;
|
|
93
75
|
}
|
|
94
|
-
this.
|
|
95
|
-
this.
|
|
76
|
+
this.voxelCache[index] = voxelId;
|
|
77
|
+
this.foundHash[index] = 2;
|
|
96
78
|
//no ao
|
|
97
|
-
this.
|
|
79
|
+
this.noCastAO[index] = voxel.isLightSource() || voxel.noAO() ? 1 : 0;
|
|
98
80
|
//state
|
|
99
81
|
const state = voxelConstructor.shapeStateTree.getState(voxel.getState());
|
|
100
|
-
this.
|
|
82
|
+
this.stateCache[index] = state;
|
|
101
83
|
//mod
|
|
102
84
|
const mod = voxelConstructor.modTree.getState(voxel.getMod());
|
|
103
|
-
this.
|
|
85
|
+
this.modCache[index] = mod;
|
|
104
86
|
this.voxelCursor.copy(voxel).process();
|
|
105
87
|
voxelConstructor.schema.position.x = x;
|
|
106
88
|
voxelConstructor.schema.position.y = y;
|
|
@@ -108,7 +90,7 @@ export class VoxelGeometryLookUp {
|
|
|
108
90
|
voxelConstructor.schema.voxel = this.voxelCursor;
|
|
109
91
|
voxelConstructor.schema.dataCursor = dataCursor;
|
|
110
92
|
const conditonalState = voxelConstructor.condtioanlShapeStateTree.getState();
|
|
111
|
-
this.
|
|
93
|
+
this.conditonalStateCache[index] = conditonalState;
|
|
112
94
|
return 1;
|
|
113
95
|
}
|
|
114
96
|
}
|
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
import { MesherDataTool } from "../Geomtry/Tools/MesherDataTools";
|
|
2
1
|
import { QuadScalarVertexData } from "../Geomtry/Primitives/QuadVertexData";
|
|
3
2
|
import { VoxelFaces } from "../../Math";
|
|
4
3
|
import { QuadVerticies } from "../Geomtry/Geometry.types";
|
|
5
4
|
import { VoxelMesh } from "../Geomtry/VoxelMesh";
|
|
6
|
-
import { VoxelMeshBVHBuilder } from "
|
|
7
|
-
import { Vec3Array, Vector3Like } from "@amodx/math";
|
|
5
|
+
import { VoxelMeshBVHBuilder } from "../Geomtry/VoxelMeshBVHBuilder";
|
|
6
|
+
import { Vec3Array, Vector3Like, Vector4Like } from "@amodx/math";
|
|
8
7
|
import { VoxelCursorInterface } from "../../Voxels/Cursor/VoxelCursor.interface.js";
|
|
9
|
-
import { DataCursorInterface } from "../../
|
|
8
|
+
import { DataCursorInterface } from "../../Voxels/Cursor/DataCursor.interface.js";
|
|
9
|
+
import { VoxelGeometryBuilderCacheSpace } from "./VoxelGeometryBuilderCacheSpace";
|
|
10
10
|
declare class VoxelVars {
|
|
11
11
|
faceFlipped: boolean;
|
|
12
12
|
textureIndex: number;
|
|
13
|
+
overlayTextures: Vector4Like;
|
|
13
14
|
light: QuadScalarVertexData;
|
|
14
15
|
ao: QuadScalarVertexData;
|
|
15
16
|
animation: QuadScalarVertexData;
|
|
16
17
|
level: QuadScalarVertexData;
|
|
17
|
-
overlayTextures: QuadScalarVertexData;
|
|
18
18
|
reset(): void;
|
|
19
19
|
}
|
|
20
|
-
export declare class
|
|
20
|
+
export declare class VoxelModelBuilder {
|
|
21
21
|
id: string;
|
|
22
22
|
materialIndex: number;
|
|
23
|
+
space: VoxelGeometryBuilderCacheSpace;
|
|
23
24
|
voxel: VoxelCursorInterface;
|
|
24
25
|
nVoxel: DataCursorInterface;
|
|
25
26
|
/**The current world position */
|
|
@@ -41,9 +42,10 @@ export declare class VoxelMesherDataTool extends MesherDataTool {
|
|
|
41
42
|
_indexStart: number;
|
|
42
43
|
startConstruction(): void;
|
|
43
44
|
endConstruction(): boolean;
|
|
45
|
+
_boundsUpdate: boolean;
|
|
46
|
+
updateBounds(bounds: [Vec3Array, Vec3Array]): void;
|
|
44
47
|
calculateFaceData(direction: VoxelFaces): true | undefined;
|
|
45
48
|
clearCalculatedData(): void;
|
|
46
|
-
|
|
47
|
-
resetAll(): this;
|
|
49
|
+
clear(): this;
|
|
48
50
|
}
|
|
49
51
|
export {};
|
|
@@ -1,28 +1,31 @@
|
|
|
1
1
|
//tools
|
|
2
|
-
import { MesherDataTool } from "../Geomtry/Tools/MesherDataTools";
|
|
3
2
|
//data
|
|
4
3
|
import { QuadScalarVertexData } from "../Geomtry/Primitives/QuadVertexData";
|
|
5
4
|
import { VoxelFaces, VoxelFacesArray } from "../../Math";
|
|
6
5
|
import { QuadVerticies } from "../Geomtry/Geometry.types";
|
|
7
|
-
import
|
|
6
|
+
import calculateFaceData from "./Common/Calc/FaceDataCalc.js";
|
|
8
7
|
import { VoxelMesh } from "../Geomtry/VoxelMesh";
|
|
9
|
-
import { Vector3Like } from "@amodx/math";
|
|
8
|
+
import { Vector3Like, Vector4Like } from "@amodx/math";
|
|
10
9
|
class VoxelVars {
|
|
11
10
|
faceFlipped = false;
|
|
12
11
|
textureIndex = 0;
|
|
12
|
+
overlayTextures = Vector4Like.Create();
|
|
13
13
|
light = new QuadScalarVertexData();
|
|
14
14
|
ao = new QuadScalarVertexData();
|
|
15
15
|
animation = new QuadScalarVertexData();
|
|
16
16
|
level = new QuadScalarVertexData();
|
|
17
|
-
overlayTextures = new QuadScalarVertexData();
|
|
18
17
|
reset() {
|
|
19
18
|
this.faceFlipped = false;
|
|
20
19
|
this.textureIndex = 0;
|
|
20
|
+
this.overlayTextures.x = 0;
|
|
21
|
+
this.overlayTextures.y = 0;
|
|
22
|
+
this.overlayTextures.z = 0;
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
|
-
export class
|
|
25
|
+
export class VoxelModelBuilder {
|
|
24
26
|
id;
|
|
25
27
|
materialIndex;
|
|
28
|
+
space;
|
|
26
29
|
voxel;
|
|
27
30
|
nVoxel;
|
|
28
31
|
/**The current world position */
|
|
@@ -37,11 +40,10 @@ export class VoxelMesherDataTool extends MesherDataTool {
|
|
|
37
40
|
lightData;
|
|
38
41
|
effects;
|
|
39
42
|
constructor(id, materialIndex) {
|
|
40
|
-
super();
|
|
41
|
-
this.id = id;
|
|
42
|
-
this.materialIndex = materialIndex;
|
|
43
43
|
// this.faceDataOverride.currentVoxel = this.voxel;
|
|
44
44
|
// this.faceDataOverride.neighborVoxel = this.nVoxel;
|
|
45
|
+
this.id = id;
|
|
46
|
+
this.materialIndex = materialIndex;
|
|
45
47
|
this.dataCalculated = [];
|
|
46
48
|
for (const face of VoxelFacesArray) {
|
|
47
49
|
this.dataCalculated[face] = false;
|
|
@@ -70,7 +72,6 @@ export class VoxelMesherDataTool extends MesherDataTool {
|
|
|
70
72
|
this.lightData[face][QuadVerticies.BottomLeft] = 0;
|
|
71
73
|
this.lightData[face][QuadVerticies.BottomRight] = 0;
|
|
72
74
|
}
|
|
73
|
-
this.startNewMesh(new VoxelMesh());
|
|
74
75
|
}
|
|
75
76
|
bounds = {
|
|
76
77
|
min: [0, 0, 0],
|
|
@@ -78,27 +79,54 @@ export class VoxelMesherDataTool extends MesherDataTool {
|
|
|
78
79
|
};
|
|
79
80
|
_indexStart = 0;
|
|
80
81
|
startConstruction() {
|
|
81
|
-
this._indexStart = this.mesh.
|
|
82
|
+
this._indexStart = this.mesh.indicieCount;
|
|
82
83
|
this.bounds.min[0] = Infinity;
|
|
83
84
|
this.bounds.min[1] = Infinity;
|
|
84
85
|
this.bounds.min[2] = Infinity;
|
|
85
86
|
this.bounds.max[0] = -Infinity;
|
|
86
87
|
this.bounds.max[1] = -Infinity;
|
|
87
88
|
this.bounds.max[2] = -Infinity;
|
|
89
|
+
this._boundsUpdate = true;
|
|
88
90
|
}
|
|
89
91
|
endConstruction() {
|
|
90
|
-
|
|
91
|
-
this.bounds.max.includes(-Infinity))
|
|
92
|
-
return false;
|
|
92
|
+
this.vars.reset();
|
|
93
93
|
if (this.bvhTool) {
|
|
94
|
-
|
|
94
|
+
if (!this._boundsUpdate)
|
|
95
|
+
return false;
|
|
96
|
+
this.bvhTool.updateVoxel(this.position.x, this.position.y, this.position.z, this._indexStart, this.materialIndex, this.mesh.indicieCount, this.bounds.min[0], this.bounds.min[1], this.bounds.min[2], this.bounds.max[0], this.bounds.max[1], this.bounds.max[2]);
|
|
97
|
+
this.bvhTool.structCursor.setIndex(0);
|
|
98
|
+
this.mesh.minBounds.x = this.bvhTool.structCursor.minX;
|
|
99
|
+
this.mesh.minBounds.y = this.bvhTool.structCursor.minY;
|
|
100
|
+
this.mesh.minBounds.z = this.bvhTool.structCursor.minZ;
|
|
101
|
+
this.mesh.maxBounds.x = this.bvhTool.structCursor.maxX;
|
|
102
|
+
this.mesh.maxBounds.y = this.bvhTool.structCursor.maxY;
|
|
103
|
+
this.mesh.maxBounds.z = this.bvhTool.structCursor.maxZ;
|
|
95
104
|
}
|
|
96
105
|
return true;
|
|
97
106
|
}
|
|
107
|
+
_boundsUpdate = false;
|
|
108
|
+
updateBounds(bounds) {
|
|
109
|
+
const origin = this.origin;
|
|
110
|
+
//min
|
|
111
|
+
if (origin.x + bounds[0][0] < this.bounds.min[0])
|
|
112
|
+
this.bounds.min[0] = origin.x + bounds[0][0];
|
|
113
|
+
if (origin.y + bounds[0][1] < this.bounds.min[1])
|
|
114
|
+
this.bounds.min[1] = origin.y + bounds[0][1];
|
|
115
|
+
if (origin.z + bounds[0][2] < this.bounds.min[2])
|
|
116
|
+
this.bounds.min[2] = origin.z + bounds[0][2];
|
|
117
|
+
//max
|
|
118
|
+
if (origin.x + bounds[1][0] > this.bounds.max[0])
|
|
119
|
+
this.bounds.max[0] = origin.x + bounds[1][0];
|
|
120
|
+
if (origin.y + bounds[1][1] > this.bounds.max[1])
|
|
121
|
+
this.bounds.max[1] = origin.y + bounds[1][1];
|
|
122
|
+
if (origin.z + bounds[1][2] > this.bounds.max[2])
|
|
123
|
+
this.bounds.max[2] = origin.z + bounds[1][2];
|
|
124
|
+
this._boundsUpdate = true;
|
|
125
|
+
}
|
|
98
126
|
calculateFaceData(direction) {
|
|
99
127
|
if (this.dataCalculated[direction])
|
|
100
128
|
return true;
|
|
101
|
-
|
|
129
|
+
calculateFaceData(direction, this);
|
|
102
130
|
this.dataCalculated[direction] = true;
|
|
103
131
|
}
|
|
104
132
|
clearCalculatedData() {
|
|
@@ -109,10 +137,7 @@ export class VoxelMesherDataTool extends MesherDataTool {
|
|
|
109
137
|
this.dataCalculated[VoxelFaces.East] = false;
|
|
110
138
|
this.dataCalculated[VoxelFaces.West] = false;
|
|
111
139
|
}
|
|
112
|
-
|
|
113
|
-
this.vars.reset();
|
|
114
|
-
}
|
|
115
|
-
resetAll() {
|
|
140
|
+
clear() {
|
|
116
141
|
this.vars.reset();
|
|
117
142
|
this.mesh.clear();
|
|
118
143
|
return this;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { VoxelPalette } from "../../Voxels/Palettes/VoxelPalette";
|
|
2
1
|
import { StringPalette } from "../../Util/StringPalette";
|
|
3
2
|
import { VoxelGeometryConstructor } from "./Nodes/VoxelGeometryConstructor";
|
|
3
|
+
import { VoxelPalettesRegister } from "../../Voxels/Data/VoxelPalettesRegister";
|
|
4
4
|
export class VoxelModelConstructorRegister {
|
|
5
5
|
static geometryPalette;
|
|
6
6
|
static geometry = [];
|
|
@@ -31,11 +31,11 @@ export class VoxelModelConstructorRegister {
|
|
|
31
31
|
if (Array.isArray(voxel)) {
|
|
32
32
|
for (const vox of voxel) {
|
|
33
33
|
this.constructors.set(vox.id, vox);
|
|
34
|
-
this.constructorsPaltte[
|
|
34
|
+
this.constructorsPaltte[VoxelPalettesRegister.voxels.getNumberId(vox.id)] = vox;
|
|
35
35
|
}
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
|
-
this.constructorsPaltte[
|
|
38
|
+
this.constructorsPaltte[VoxelPalettesRegister.voxels.getNumberId(voxel.id)] = voxel;
|
|
39
39
|
this.constructors.set(voxel.id, voxel);
|
|
40
40
|
}
|
|
41
41
|
static registerGeometry(geometries) {
|