@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,11 +1,13 @@
|
|
|
1
1
|
import { VoxelCursorInterface } from "./VoxelCursor.interface";
|
|
2
|
-
import {
|
|
3
|
-
import { VoxelLevelReader } from "
|
|
2
|
+
import { VoxelPalettesRegister } from "../../Voxels/Data/VoxelPalettesRegister";
|
|
3
|
+
import { VoxelLevelReader } from "./VoxelLevelReader";
|
|
4
4
|
export class VoxelCursor extends VoxelCursorInterface {
|
|
5
5
|
static VoxelDataToRaw(data, light = 0) {
|
|
6
|
-
const id = (data.id !== undefined &&
|
|
6
|
+
const id = (data.id !== undefined &&
|
|
7
|
+
VoxelPalettesRegister.voxels.getNumberId(data.id)) ||
|
|
8
|
+
0;
|
|
7
9
|
const secondaryId = (data.secondaryVoxelId !== undefined &&
|
|
8
|
-
|
|
10
|
+
VoxelPalettesRegister.voxels.getNumberId(data.secondaryVoxelId)) ||
|
|
9
11
|
0;
|
|
10
12
|
let levleData = 0;
|
|
11
13
|
if (data.level !== undefined)
|
|
@@ -14,13 +16,12 @@ export class VoxelCursor extends VoxelCursorInterface {
|
|
|
14
16
|
levleData = VoxelLevelReader.setLevelState(levleData, data.levelState);
|
|
15
17
|
return [id, light, levleData, data.state || 0, data.mod || 0, secondaryId];
|
|
16
18
|
}
|
|
17
|
-
ids =
|
|
18
|
-
light =
|
|
19
|
-
level =
|
|
20
|
-
state =
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
ids = new Uint16Array(1);
|
|
20
|
+
light = new Uint16Array(1);
|
|
21
|
+
level = new Uint8Array(1);
|
|
22
|
+
state = new Uint16Array(1);
|
|
23
|
+
mod = new Uint16Array(1);
|
|
24
|
+
secondary = new Uint16Array(1);
|
|
23
25
|
loadIn() { }
|
|
24
|
-
updateVoxel(mode) {
|
|
25
|
-
}
|
|
26
|
+
updateVoxel(mode) { }
|
|
26
27
|
}
|
|
@@ -20,8 +20,7 @@ export declare class VoxelLightData {
|
|
|
20
20
|
mixLight(l1: number, l2: number): number;
|
|
21
21
|
getRGB(sl: number): number;
|
|
22
22
|
setRGB(value: number, sl: number): number;
|
|
23
|
-
|
|
24
|
-
encodeLightIntoVoxelData(voxelData: number, encodedLight: number): number;
|
|
23
|
+
createLightValue(s: number, r: number, g: number, b: number): number;
|
|
25
24
|
/**# Set Light Values
|
|
26
25
|
* ---
|
|
27
26
|
* Give an array of light values it will return an encoded light number.
|
|
@@ -37,8 +36,8 @@ export declare class VoxelLightData {
|
|
|
37
36
|
* - 3: Blue Light
|
|
38
37
|
* @param value
|
|
39
38
|
*/
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
getLightValuesArray(value: number): AllLight;
|
|
40
|
+
getLightValuesArrayToRef(value: number, values: AllLight): AllLight;
|
|
42
41
|
addLightValues(sl: number, sl2: number): number;
|
|
43
42
|
divideLightValue(sl: number, divisor: number): number;
|
|
44
43
|
}
|
|
@@ -81,11 +81,12 @@ export class VoxelLightData {
|
|
|
81
81
|
return 0;
|
|
82
82
|
return (sl & ~0xfff0) | (value << 4);
|
|
83
83
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
84
|
+
createLightValue(s, r, g, b) {
|
|
85
|
+
let v = 0;
|
|
86
|
+
v = this.setS(s, v);
|
|
87
|
+
v = this.setR(r, v);
|
|
88
|
+
v = this.setG(r, v);
|
|
89
|
+
return this.setB(r, v);
|
|
89
90
|
}
|
|
90
91
|
/**# Set Light Values
|
|
91
92
|
* ---
|
|
@@ -107,14 +108,14 @@ export class VoxelLightData {
|
|
|
107
108
|
* - 3: Blue Light
|
|
108
109
|
* @param value
|
|
109
110
|
*/
|
|
110
|
-
|
|
111
|
+
getLightValuesArray(value) {
|
|
111
112
|
this._lightValues[0] = this.getS(value);
|
|
112
113
|
this._lightValues[1] = this.getR(value);
|
|
113
114
|
this._lightValues[2] = this.getG(value);
|
|
114
115
|
this._lightValues[3] = this.getB(value);
|
|
115
116
|
return this._lightValues;
|
|
116
117
|
}
|
|
117
|
-
|
|
118
|
+
getLightValuesArrayToRef(value, values) {
|
|
118
119
|
values[0] = this.getS(value);
|
|
119
120
|
values[1] = this.getR(value);
|
|
120
121
|
values[2] = this.getG(value);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { StringPalette } from "../../Util/StringPalette";
|
|
2
|
+
export declare class VoxelPalettesRegister {
|
|
3
|
+
static material: StringPalette;
|
|
4
|
+
static substance: StringPalette;
|
|
5
|
+
static voxels: StringPalette;
|
|
6
|
+
static voxelNametoIdMap: Map<string, string>;
|
|
7
|
+
static voxelIdToNameMap: Map<string, string>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { StringPalette } from "../../Util/StringPalette";
|
|
2
|
+
export class VoxelPalettesRegister {
|
|
3
|
+
static material = new StringPalette();
|
|
4
|
+
static substance = new StringPalette();
|
|
5
|
+
static voxels = new StringPalette();
|
|
6
|
+
static voxelNametoIdMap = new Map();
|
|
7
|
+
static voxelIdToNameMap = new Map();
|
|
8
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export declare enum VoxelTagIds {
|
|
2
|
+
substance = "dve_substance",
|
|
3
|
+
renderedMaterial = "dve_rendered_material",
|
|
4
|
+
voxelMaterial = "dve_voxel_material",
|
|
5
|
+
hardness = "dve_hardness",
|
|
6
|
+
colliderID = "dve_collider_id",
|
|
7
|
+
checkCollisions = "dve_check_collisions",
|
|
8
|
+
isLightSource = "dve_is_light_source",
|
|
9
|
+
noAO = "dve_no_ao",
|
|
10
|
+
isTransparent = "dve_is_transparent",
|
|
11
|
+
lightValue = "dve_light_value",
|
|
12
|
+
canHaveSecondary = "dve_can_have_secondary"
|
|
13
|
+
}
|
|
14
|
+
export interface VoxelTags {
|
|
15
|
+
/** The material used to render the voxel. Used by the engine to assign meshes to the proper material. */
|
|
16
|
+
[VoxelTagIds.renderedMaterial]: string;
|
|
17
|
+
/** A description of the material used for the voxel. Not used by the engine directly. */
|
|
18
|
+
[VoxelTagIds.voxelMaterial]: string;
|
|
19
|
+
/** Specifies the substance of the voxel.
|
|
20
|
+
* The voxel will inherit properties from the substance and change how it acts in the world.
|
|
21
|
+
* Properties include being solid or liquid.
|
|
22
|
+
* */
|
|
23
|
+
[VoxelTagIds.substance]: string;
|
|
24
|
+
/** Indicates whether the voxel is a light source. */
|
|
25
|
+
[VoxelTagIds.isLightSource]: boolean;
|
|
26
|
+
/** Indicates if the voxel lets light through */
|
|
27
|
+
[VoxelTagIds.isTransparent]: boolean;
|
|
28
|
+
/** Disables ambient occlusion for this voxel if set to true. */
|
|
29
|
+
[VoxelTagIds.noAO]: boolean;
|
|
30
|
+
/** Defines the light value emitted by the voxel (r, g, z). */
|
|
31
|
+
[VoxelTagIds.lightValue]: [r: number, g: number, z: number] | number;
|
|
32
|
+
/** The collider ID for the voxel, used for collision detection. */
|
|
33
|
+
[VoxelTagIds.colliderID]: string;
|
|
34
|
+
/** Specifies if the voxel participates in collision checks. */
|
|
35
|
+
[VoxelTagIds.checkCollisions]: boolean;
|
|
36
|
+
/** Indicates if the voxel can have a secondary voxel. */
|
|
37
|
+
[VoxelTagIds.canHaveSecondary]: boolean;
|
|
38
|
+
/** The hardness level of the voxel, affecting how it is broken or interacted with. */
|
|
39
|
+
[VoxelTagIds.hardness]: number;
|
|
40
|
+
}
|
|
41
|
+
export declare enum VoxelSubstanceTagIdds {
|
|
42
|
+
parent = "dve_parent_substance",
|
|
43
|
+
isSolid = "dve_is_solid",
|
|
44
|
+
isTransparent = "dve_is_transparent",
|
|
45
|
+
isLiquid = "dve_is_liquid",
|
|
46
|
+
flowRate = "dve_flow_rate",
|
|
47
|
+
isWindAffected = "dve_is_wind_affected"
|
|
48
|
+
}
|
|
49
|
+
export interface VoxelSubstanceTags {
|
|
50
|
+
[VoxelSubstanceTagIdds.parent]: string;
|
|
51
|
+
[VoxelSubstanceTagIdds.isTransparent]: boolean;
|
|
52
|
+
[VoxelSubstanceTagIdds.isSolid]: boolean;
|
|
53
|
+
[VoxelSubstanceTagIdds.isLiquid]: boolean;
|
|
54
|
+
[VoxelSubstanceTagIdds.flowRate]: number;
|
|
55
|
+
[VoxelSubstanceTagIdds.isWindAffected]: boolean;
|
|
56
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export var VoxelTagIds;
|
|
2
|
+
(function (VoxelTagIds) {
|
|
3
|
+
VoxelTagIds["substance"] = "dve_substance";
|
|
4
|
+
VoxelTagIds["renderedMaterial"] = "dve_rendered_material";
|
|
5
|
+
VoxelTagIds["voxelMaterial"] = "dve_voxel_material";
|
|
6
|
+
VoxelTagIds["hardness"] = "dve_hardness";
|
|
7
|
+
VoxelTagIds["colliderID"] = "dve_collider_id";
|
|
8
|
+
VoxelTagIds["checkCollisions"] = "dve_check_collisions";
|
|
9
|
+
VoxelTagIds["isLightSource"] = "dve_is_light_source";
|
|
10
|
+
VoxelTagIds["noAO"] = "dve_no_ao";
|
|
11
|
+
VoxelTagIds["isTransparent"] = "dve_is_transparent";
|
|
12
|
+
VoxelTagIds["lightValue"] = "dve_light_value";
|
|
13
|
+
VoxelTagIds["canHaveSecondary"] = "dve_can_have_secondary";
|
|
14
|
+
})(VoxelTagIds || (VoxelTagIds = {}));
|
|
15
|
+
export var VoxelSubstanceTagIdds;
|
|
16
|
+
(function (VoxelSubstanceTagIdds) {
|
|
17
|
+
VoxelSubstanceTagIdds["parent"] = "dve_parent_substance";
|
|
18
|
+
VoxelSubstanceTagIdds["isSolid"] = "dve_is_solid";
|
|
19
|
+
VoxelSubstanceTagIdds["isTransparent"] = "dve_is_transparent";
|
|
20
|
+
VoxelSubstanceTagIdds["isLiquid"] = "dve_is_liquid";
|
|
21
|
+
VoxelSubstanceTagIdds["flowRate"] = "dve_flow_rate";
|
|
22
|
+
VoxelSubstanceTagIdds["isWindAffected"] = "dve_is_wind_affected";
|
|
23
|
+
})(VoxelSubstanceTagIdds || (VoxelSubstanceTagIdds = {}));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { StateSchema } from "
|
|
2
|
-
import { StateTreeReader } from "
|
|
1
|
+
import { StateSchema } from "../State/Schema/StateSchema";
|
|
2
|
+
import { StateTreeReader } from "../State/StateTreeReader";
|
|
3
3
|
export type VoxelTagStatesData = Record<string, {
|
|
4
4
|
tree: any;
|
|
5
5
|
treePalette: any;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { StateSchema } from "
|
|
3
|
-
import { StateTreeReader } from "
|
|
4
|
-
import { SchemaRegister } from "
|
|
1
|
+
import { VoxelPalettesRegister } from "./VoxelPalettesRegister";
|
|
2
|
+
import { StateSchema } from "../State/Schema/StateSchema";
|
|
3
|
+
import { StateTreeReader } from "../State/StateTreeReader";
|
|
4
|
+
import { SchemaRegister } from "../State/SchemaRegister";
|
|
5
5
|
export class VoxelTagStates {
|
|
6
6
|
static voxelTags = [];
|
|
7
7
|
static toJSON() {
|
|
@@ -18,7 +18,7 @@ export class VoxelTagStates {
|
|
|
18
18
|
data.forEach((v, index) => {
|
|
19
19
|
if (!v)
|
|
20
20
|
return;
|
|
21
|
-
const stateSceham = new StateSchema(SchemaRegister.modelStaeBaseSchemaData.get(SchemaRegister.voxelModelMap.get(
|
|
21
|
+
const stateSceham = new StateSchema(SchemaRegister.modelStaeBaseSchemaData.get(SchemaRegister.voxelModelMap.get(VoxelPalettesRegister.voxels.getStringId(index))));
|
|
22
22
|
for (const tag in v) {
|
|
23
23
|
this.register(index, tag, stateSceham, v[tag].tree, v[tag].treePalette);
|
|
24
24
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { VoxelSubstanceTags, VoxelTags } from "./VoxelTag.types";
|
|
2
|
+
export declare class VoxelTagsRegister {
|
|
3
|
+
static IncludedVoxelTags: string[];
|
|
4
|
+
static IncludedSubstnacesTags: string[];
|
|
5
|
+
static VoxelTagDefaults: Record<string, any>;
|
|
6
|
+
static VoxelTags: VoxelTags[];
|
|
7
|
+
static SubstanceStagDefaults: Record<string, any>;
|
|
8
|
+
static SubstanceStags: VoxelSubstanceTags[];
|
|
9
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { VoxelSubstanceTagIdds as VoxelSubstanceTagIds, VoxelTagIds, } from "./VoxelTag.types";
|
|
2
|
+
export class VoxelTagsRegister {
|
|
3
|
+
static IncludedVoxelTags = [
|
|
4
|
+
VoxelTagIds.substance,
|
|
5
|
+
VoxelTagIds.renderedMaterial,
|
|
6
|
+
VoxelTagIds.voxelMaterial,
|
|
7
|
+
VoxelTagIds.hardness,
|
|
8
|
+
VoxelTagIds.colliderID,
|
|
9
|
+
VoxelTagIds.checkCollisions,
|
|
10
|
+
VoxelTagIds.isLightSource,
|
|
11
|
+
VoxelTagIds.lightValue,
|
|
12
|
+
VoxelTagIds.noAO,
|
|
13
|
+
VoxelTagIds.isTransparent,
|
|
14
|
+
VoxelTagIds.canHaveSecondary,
|
|
15
|
+
];
|
|
16
|
+
static IncludedSubstnacesTags = [
|
|
17
|
+
VoxelSubstanceTagIds.parent,
|
|
18
|
+
VoxelSubstanceTagIds.isSolid,
|
|
19
|
+
VoxelSubstanceTagIds.isTransparent,
|
|
20
|
+
VoxelSubstanceTagIds.isLiquid,
|
|
21
|
+
VoxelSubstanceTagIds.flowRate,
|
|
22
|
+
VoxelSubstanceTagIds.isWindAffected,
|
|
23
|
+
];
|
|
24
|
+
static VoxelTagDefaults = {
|
|
25
|
+
[VoxelTagIds.renderedMaterial]: "dve_solid",
|
|
26
|
+
[VoxelTagIds.substance]: "dve_solid",
|
|
27
|
+
[VoxelTagIds.colliderID]: "dve_cube",
|
|
28
|
+
};
|
|
29
|
+
static VoxelTags = [];
|
|
30
|
+
static SubstanceStagDefaults = {};
|
|
31
|
+
static SubstanceStags = [];
|
|
32
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { StateCompareOperationsMap, StateLogicOperationsMap, } from "../State/State.types";
|
|
2
2
|
import { StringPalette } from "../../Util/StringPalette";
|
|
3
|
-
import {
|
|
4
|
-
import { VoxelTagStates } from "../
|
|
5
|
-
import {
|
|
3
|
+
import { VoxelModelRuleBuilderRegister } from "../../Models/Rules/VoxelModelRuleBuilderRegister";
|
|
4
|
+
import { VoxelTagStates } from "../Data/VoxelTagStates";
|
|
5
|
+
import { VoxelPalettesRegister } from "../Data/VoxelPalettesRegister";
|
|
6
6
|
import { StateSchema } from "../State/Schema/StateSchema";
|
|
7
7
|
function bitsNeeded(n) {
|
|
8
8
|
if (n < 0)
|
|
@@ -182,7 +182,7 @@ export function BuildStateData(model, geoPalette) {
|
|
|
182
182
|
if (geometryLinkPalette.isRegistered(node.id))
|
|
183
183
|
continue;
|
|
184
184
|
const linkId = geometryLinkPalette.register(node.id);
|
|
185
|
-
geometryLinkStateMap[linkId] = geoPalette.getNumberId(
|
|
185
|
+
geometryLinkStateMap[linkId] = geoPalette.getNumberId(VoxelModelRuleBuilderRegister.getGeometryLinkId(node));
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
188
|
//add geomtry from condiotnal shape states
|
|
@@ -192,7 +192,7 @@ export function BuildStateData(model, geoPalette) {
|
|
|
192
192
|
if (geometryLinkPalette.isRegistered(node.id))
|
|
193
193
|
continue;
|
|
194
194
|
const linkId = geometryLinkPalette.register(node.id);
|
|
195
|
-
geometryLinkStateMap[linkId] = geoPalette.getNumberId(
|
|
195
|
+
geometryLinkStateMap[linkId] = geoPalette.getNumberId(VoxelModelRuleBuilderRegister.getGeometryLinkId(node));
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
198
|
const shapeStateRelativeGeometryMap = [];
|
|
@@ -206,15 +206,15 @@ export function BuildStateData(model, geoPalette) {
|
|
|
206
206
|
const shapeStateRecord = {};
|
|
207
207
|
for (const key in data.shapeStatesNodes) {
|
|
208
208
|
shapeStateGeoLinkPalette.push(data.shapeStatesNodes[key].map((_) => geometryLinkPalette.getNumberId(_.id)));
|
|
209
|
-
shapeStateGeometryPalette.push(data.shapeStatesNodes[key].map((_) => geoPalette.getNumberId(
|
|
209
|
+
shapeStateGeometryPalette.push(data.shapeStatesNodes[key].map((_) => geoPalette.getNumberId(VoxelModelRuleBuilderRegister.getGeometryLinkId(_))));
|
|
210
210
|
shapeStateRecord[key] = shapeStateGeometryPalette.length - 1;
|
|
211
211
|
shapeStateRelativeGeometryMap[shapeStateRecord[key]] ??= [];
|
|
212
212
|
const nodeData = data.shapeStatesNodes[key];
|
|
213
213
|
for (const node of nodeData) {
|
|
214
|
-
shapeStateRelativeGeometryMap[shapeStateRecord[key]][geoPalette.getNumberId(
|
|
214
|
+
shapeStateRelativeGeometryMap[shapeStateRecord[key]][geoPalette.getNumberId(VoxelModelRuleBuilderRegister.getGeometryLinkId(node))] = relativeGeoId;
|
|
215
215
|
relativeGeometryByteIndexMap[relativeGeoId] = relativeByteCount;
|
|
216
216
|
relativeGeoId++;
|
|
217
|
-
relativeByteCount += Math.ceil(
|
|
217
|
+
relativeByteCount += Math.ceil(VoxelModelRuleBuilderRegister.getGeomtryFromLink(node).faceCount / 8);
|
|
218
218
|
}
|
|
219
219
|
addPathToTree(shapeStateTree, key
|
|
220
220
|
.split(",")
|
|
@@ -229,17 +229,17 @@ export function BuildStateData(model, geoPalette) {
|
|
|
229
229
|
const compareOperations = Object.keys(StateCompareOperationsMap);
|
|
230
230
|
for (const key in data.shapeStatesConditonalNodes) {
|
|
231
231
|
condiotnalShapeStateNodePalette.push(data.shapeStatesConditonalNodes[key].map((_) => geometryLinkPalette.getNumberId(_.id)));
|
|
232
|
-
condiotnalShapeStateGeometryPalette.push(data.shapeStatesConditonalNodes[key].map((_) => geoPalette.getNumberId(
|
|
232
|
+
condiotnalShapeStateGeometryPalette.push(data.shapeStatesConditonalNodes[key].map((_) => geoPalette.getNumberId(VoxelModelRuleBuilderRegister.getGeometryLinkId(_))));
|
|
233
233
|
condiotnalShapeStateNodeRecord[key] =
|
|
234
234
|
condiotnalShapeStateGeometryPalette.length - 1;
|
|
235
235
|
condiotnalShapeStateRelativeGeometryMap[condiotnalShapeStateNodeRecord[key]] ??= [];
|
|
236
236
|
const nodeData = data.shapeStatesConditonalNodes[key];
|
|
237
237
|
for (const node of nodeData) {
|
|
238
|
-
condiotnalShapeStateRelativeGeometryMap[condiotnalShapeStateNodeRecord[key]][geoPalette.getNumberId(
|
|
238
|
+
condiotnalShapeStateRelativeGeometryMap[condiotnalShapeStateNodeRecord[key]][geoPalette.getNumberId(VoxelModelRuleBuilderRegister.getGeometryLinkId(node))] =
|
|
239
239
|
relativeGeoId;
|
|
240
240
|
relativeGeometryByteIndexMap[relativeGeoId] = relativeByteCount;
|
|
241
241
|
relativeGeoId++;
|
|
242
|
-
relativeByteCount += Math.ceil(
|
|
242
|
+
relativeByteCount += Math.ceil(VoxelModelRuleBuilderRegister.getGeomtryFromLink(node).faceCount / 8);
|
|
243
243
|
}
|
|
244
244
|
const statement = [];
|
|
245
245
|
const nodes = key.split(" ");
|
|
@@ -334,7 +334,7 @@ export function BuildStateData(model, geoPalette) {
|
|
|
334
334
|
const modStatePalette = [];
|
|
335
335
|
const modStateRecord = {};
|
|
336
336
|
for (const tag of tagEffects) {
|
|
337
|
-
VoxelTagStates.register(
|
|
337
|
+
VoxelTagStates.register(VoxelPalettesRegister.voxels.getNumberId(voxelId), tag.tagId, schema, tag.tree, tag.treePalette);
|
|
338
338
|
}
|
|
339
339
|
const { baseSchema, schemaIdPalette, schemaValuePalette } = buildSchemas(voxelData.modSchema || [], voxelData.modRelationSchema || []);
|
|
340
340
|
for (const key in voxelData.inputs) {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { VoxelData } from "../Types/Voxel.types";
|
|
2
|
+
import { VoxelMaterialData } from "../Types/VoxelMaterial.types";
|
|
3
|
+
import { VoxelSubstanceData } from "../Types/VoxelSubstances.types";
|
|
4
|
+
import { CompiledVoxelTagAndPaletteData } from "../Types/VoxelModelCompiledData.types";
|
|
5
|
+
export type BuildTagAndPaletteDataProps = {
|
|
6
|
+
voxels: VoxelData[];
|
|
7
|
+
voxelsOverrides?: Record<string, (value: any) => any>;
|
|
8
|
+
substances: VoxelSubstanceData[];
|
|
9
|
+
substancesOverrides?: Record<string, (value: any) => any>;
|
|
10
|
+
materials: VoxelMaterialData[];
|
|
11
|
+
materialsOverrides?: Record<string, (value: any) => any>;
|
|
12
|
+
};
|
|
13
|
+
export declare function BuildTagAndPaletteData(props: BuildTagAndPaletteDataProps): CompiledVoxelTagAndPaletteData;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { VoxelTagsRegister } from "../Data/VoxelTagsRegister";
|
|
2
|
+
import { VoxelPalettesRegister } from "../Data/VoxelPalettesRegister";
|
|
3
|
+
export function BuildTagAndPaletteData(props) {
|
|
4
|
+
for (const voxel of props.voxels) {
|
|
5
|
+
const tags = {};
|
|
6
|
+
const voxelId = VoxelPalettesRegister.voxels.register(voxel.id);
|
|
7
|
+
VoxelPalettesRegister.voxelIdToNameMap.set(voxel.id, voxel.name || "");
|
|
8
|
+
VoxelPalettesRegister.voxelNametoIdMap.set(voxel.name || voxel.id, voxel.id);
|
|
9
|
+
for (const tag of VoxelTagsRegister.IncludedVoxelTags) {
|
|
10
|
+
if (voxel.properties[tag] === undefined) {
|
|
11
|
+
tags[tag] = VoxelTagsRegister.VoxelTagDefaults[tag] || false;
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
if (props?.voxelsOverrides?.[tag]) {
|
|
15
|
+
tags[tag] = props.voxelsOverrides[tag](voxel.properties[tag]);
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
tags[tag] = voxel.properties[tag];
|
|
19
|
+
}
|
|
20
|
+
VoxelTagsRegister.VoxelTags[voxelId] = tags;
|
|
21
|
+
}
|
|
22
|
+
for (const substance of props.substances) {
|
|
23
|
+
const tags = {};
|
|
24
|
+
const substanceId = VoxelPalettesRegister.substance.register(substance.id);
|
|
25
|
+
for (const tag of VoxelTagsRegister.IncludedSubstnacesTags) {
|
|
26
|
+
if (substance.properties[tag] === undefined) {
|
|
27
|
+
tags[tag] =
|
|
28
|
+
VoxelTagsRegister.SubstanceStagDefaults[tag] || false;
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if (props?.substancesOverrides?.[tag]) {
|
|
32
|
+
tags[tag] = props.substancesOverrides[tag](substance.properties[tag]);
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
tags[tag] = substance.properties[tag];
|
|
36
|
+
}
|
|
37
|
+
VoxelTagsRegister.SubstanceStags[substanceId] = tags;
|
|
38
|
+
}
|
|
39
|
+
for (const material of props.materials) {
|
|
40
|
+
VoxelPalettesRegister.material.register(material.id);
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
data: {
|
|
44
|
+
palette: VoxelPalettesRegister.voxels._palette,
|
|
45
|
+
tags: VoxelTagsRegister.VoxelTags,
|
|
46
|
+
idToNameMap: [...VoxelPalettesRegister.voxelIdToNameMap.entries()],
|
|
47
|
+
nameToIdMap: [...VoxelPalettesRegister.voxelNametoIdMap.entries()],
|
|
48
|
+
},
|
|
49
|
+
substances: {
|
|
50
|
+
tags: VoxelTagsRegister.SubstanceStags,
|
|
51
|
+
palette: VoxelPalettesRegister.substance._palette,
|
|
52
|
+
},
|
|
53
|
+
materials: { palette: VoxelPalettesRegister.material._palette },
|
|
54
|
+
};
|
|
55
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PaintVoxelData } from "../Types/Voxel.types";
|
|
2
2
|
import { SchemaRegister } from "../State/SchemaRegister";
|
|
3
|
-
import {
|
|
3
|
+
import { VoxelPalettesRegister } from "../../Voxels/Data/VoxelPalettesRegister";
|
|
4
4
|
export class VoxelNamedState {
|
|
5
5
|
voxelId;
|
|
6
6
|
data;
|
|
@@ -82,11 +82,11 @@ export class VoxelIndex {
|
|
|
82
82
|
if (!VoxelIndex.instance)
|
|
83
83
|
VoxelIndex.instance = this;
|
|
84
84
|
for (const voxelData of data) {
|
|
85
|
+
this.dataMap.set(voxelData.id, voxelData);
|
|
85
86
|
const namedStates = voxelData.properties["dve_named_states"];
|
|
86
87
|
if (!namedStates)
|
|
87
88
|
continue;
|
|
88
89
|
const states = new VoxelNamedStateContainer(voxelData.id, namedStates.map((_) => new VoxelNamedState(voxelData.id, _)));
|
|
89
|
-
this.dataMap.set(voxelData.id, voxelData);
|
|
90
90
|
this.stateArray.push(states);
|
|
91
91
|
this.states.set(voxelData.id, states);
|
|
92
92
|
for (const [id, state] of states.states) {
|
|
@@ -119,7 +119,7 @@ export class VoxelIndex {
|
|
|
119
119
|
}
|
|
120
120
|
getStateFromRawData(data) {
|
|
121
121
|
const [id, light, shapeState, secondary, mod] = data;
|
|
122
|
-
const conatiner = this.states.get(
|
|
122
|
+
const conatiner = this.states.get(VoxelPalettesRegister.voxels.getStringId(id));
|
|
123
123
|
if (!conatiner)
|
|
124
124
|
return false;
|
|
125
125
|
for (const state of conatiner?.stateArray) {
|
package/Voxels/InitVoxelData.js
CHANGED
|
@@ -4,26 +4,18 @@ import { orientedCube, pillarCube, simpleCube, simpleHalfCube, } from "../Models
|
|
|
4
4
|
import { diagonalFlatPanelEastWest, diagonalFlatPanelWestEast, thinPanelDown, thinPanelSouth, thinPanelWest, } from "../Models/Defaults/PanelVoxelGeometry";
|
|
5
5
|
import { stair } from "../Models/Defaults/StairVoxelModel";
|
|
6
6
|
import { liquidGeometry, liquidModel, } from "../Models/Defaults/LiquidVoxelModel";
|
|
7
|
-
import {
|
|
8
|
-
import { VoxelStructIds } from "./Types/Voxel.types";
|
|
7
|
+
import { VoxelModelRuleBuilderRegister } from "../Models/Rules/VoxelModelRuleBuilderRegister";
|
|
9
8
|
import { BuildRules } from "../Models/Rules/Functions/BuildRules";
|
|
10
9
|
import { BuildStateData } from "./Functions/BuildStateData";
|
|
11
10
|
import { BuildFinalInputs } from "../Models/Rules/Functions/BuildFinalInputs";
|
|
12
11
|
import { SchemaRegister } from "../Voxels/State/SchemaRegister";
|
|
13
12
|
import { simpleCrossedPannel, simpleThinPannel, } from "../Models/Defaults/PanelVoxelModels";
|
|
14
|
-
import { VoxelTagStates } from "
|
|
13
|
+
import { VoxelTagStates } from "./Data/VoxelTagStates";
|
|
15
14
|
import { VoxelIndex } from "../Voxels/Indexes/VoxelIndex";
|
|
16
15
|
import { CacheManager } from "../Cache/CacheManager";
|
|
17
16
|
import { VoxelLightData } from "./Cursor/VoxelLightData";
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import { VoxelDataGenerator } from "./Segments/VoxelDataGenerator";
|
|
21
|
-
import { SubstanceStructBuilder } from "./Structs/Builder/SubstanceStructBuilder";
|
|
22
|
-
import { MappedDataRegister } from "../Data/Register/MappedDataRegister";
|
|
23
|
-
import { MaterialPalette } from "./Palettes/MaterialPalette";
|
|
24
|
-
import { VoxelStruct } from "./Structs/VoxelStruct";
|
|
25
|
-
import { SubstanceStruct } from "./Structs/SubstanceStruct";
|
|
26
|
-
import { VoxelStructBuilder } from "./Structs/Builder/VoxelStructBuilder";
|
|
17
|
+
import { VoxelTagIds } from "./Data/VoxelTag.types";
|
|
18
|
+
import { BuildTagAndPaletteData } from "./Functions/BuildTagAndPaletteData";
|
|
27
19
|
function GetModelData(data) {
|
|
28
20
|
if (CacheManager.cacheLoadEnabled && CacheManager.cachedData) {
|
|
29
21
|
const syncData = CacheManager.cachedData.models;
|
|
@@ -38,10 +30,10 @@ function GetModelData(data) {
|
|
|
38
30
|
VoxelTagStates.load(syncData.tagState);
|
|
39
31
|
return syncData;
|
|
40
32
|
}
|
|
41
|
-
|
|
42
|
-
|
|
33
|
+
VoxelModelRuleBuilderRegister.registerGeometry(cube, halfDownCube, halfSouthCube, halfWestCube, quaterCubeSouthNorth, quaterCubeUpDown, quaterCubeWestEast, eighthCube, thinPanelDown, thinPanelSouth, thinPanelWest, diagonalFlatPanelEastWest, diagonalFlatPanelWestEast, fencePost, fenceEastWest, fenceNorthsouth, chainGeometry, carpetGeometry, candlesGeometry1, candlesGeometry2, candlesGeometry3, candlesGeometry4, liquidGeometry, ...leverGeometry, ...(data.geometry || []));
|
|
34
|
+
VoxelModelRuleBuilderRegister.registerModels(simpleCube, orientedCube, simpleHalfCube, pillarCube, simpleThinPannel, stair, simpleCrossedPannel, chainModel, carpetModel, candlesModel, leverModel, fence, liquidModel, ...(data.models || []));
|
|
43
35
|
const syncData = {
|
|
44
|
-
geometryPalette:
|
|
36
|
+
geometryPalette: VoxelModelRuleBuilderRegister.geometryPalette._palette,
|
|
45
37
|
geometry: [],
|
|
46
38
|
models: [],
|
|
47
39
|
voxels: [],
|
|
@@ -51,13 +43,13 @@ function GetModelData(data) {
|
|
|
51
43
|
const voxelData = voxel.properties["dve_model_data"];
|
|
52
44
|
if (!voxelData)
|
|
53
45
|
continue;
|
|
54
|
-
|
|
55
|
-
const model =
|
|
46
|
+
VoxelModelRuleBuilderRegister.registerVoxel(voxel.id, voxelData);
|
|
47
|
+
const model = VoxelModelRuleBuilderRegister.models.get(voxelData.id);
|
|
56
48
|
if (!model)
|
|
57
49
|
throw new Error(`Voxel model with id ${voxelData.id} does not exist.`);
|
|
58
50
|
model.voxels.set(voxel.id, voxelData);
|
|
59
51
|
}
|
|
60
|
-
for (const [mainKey, mainGeo] of
|
|
52
|
+
for (const [mainKey, mainGeo] of VoxelModelRuleBuilderRegister.geometry) {
|
|
61
53
|
if (mainGeo.data.ogData.doNotBuildRules) {
|
|
62
54
|
syncData.geometry.push({
|
|
63
55
|
id: mainKey,
|
|
@@ -66,15 +58,15 @@ function GetModelData(data) {
|
|
|
66
58
|
});
|
|
67
59
|
continue;
|
|
68
60
|
}
|
|
69
|
-
const output = BuildRules(mainGeo,
|
|
61
|
+
const output = BuildRules(mainGeo, VoxelModelRuleBuilderRegister.geometryPalette);
|
|
70
62
|
syncData.geometry.push({
|
|
71
63
|
id: mainKey,
|
|
72
64
|
nodes: mainGeo.data.nodes,
|
|
73
65
|
...output,
|
|
74
66
|
});
|
|
75
67
|
}
|
|
76
|
-
for (const [mainKey, model] of
|
|
77
|
-
const stateData = BuildStateData(model,
|
|
68
|
+
for (const [mainKey, model] of VoxelModelRuleBuilderRegister.models) {
|
|
69
|
+
const stateData = BuildStateData(model, VoxelModelRuleBuilderRegister.geometryPalette);
|
|
78
70
|
model.stateData = stateData;
|
|
79
71
|
SchemaRegister.registerModel(mainKey, stateData.schema);
|
|
80
72
|
syncData.models.push({
|
|
@@ -98,13 +90,14 @@ function GetModelData(data) {
|
|
|
98
90
|
/* for (const [mainKey, geometry] of VoxelModelManager.geometry) {
|
|
99
91
|
BuildGeomtryInputs(geometry);
|
|
100
92
|
} */
|
|
101
|
-
for (const [mainKey, model] of
|
|
93
|
+
for (const [mainKey, model] of VoxelModelRuleBuilderRegister.models) {
|
|
102
94
|
const { shapeStateVoxelInputs, conditionalShapeStateVoxelInputs, transparentVoxelFaceIndexes, } = BuildFinalInputs(model);
|
|
103
95
|
for (const v in shapeStateVoxelInputs) {
|
|
104
96
|
const stateData = model.voxelModData.get(v);
|
|
105
97
|
SchemaRegister.registerVoxel(v, mainKey, stateData.modSchema);
|
|
106
98
|
syncData.voxels.push({
|
|
107
99
|
id: v,
|
|
100
|
+
materialId: VoxelIndex.instance.dataMap.get(v)?.properties["dve_rendered_material"] || "dve_solid",
|
|
108
101
|
modelId: mainKey,
|
|
109
102
|
transparentFaceIndex: transparentVoxelFaceIndexes[v].data,
|
|
110
103
|
modSchema: stateData.modSchema,
|
|
@@ -122,7 +115,7 @@ function GetModelData(data) {
|
|
|
122
115
|
}
|
|
123
116
|
export function InitVoxelData(data) {
|
|
124
117
|
const lightData = new VoxelLightData();
|
|
125
|
-
|
|
118
|
+
new VoxelIndex(data.voxels);
|
|
126
119
|
const materials = [
|
|
127
120
|
{ id: "dve_solid", properties: {} },
|
|
128
121
|
{ id: "dve_flora", properties: {} },
|
|
@@ -141,7 +134,6 @@ export function InitVoxelData(data) {
|
|
|
141
134
|
},
|
|
142
135
|
...(data.materials || []),
|
|
143
136
|
];
|
|
144
|
-
MaterialDataGenerator.generate(materials);
|
|
145
137
|
const substances = [
|
|
146
138
|
{
|
|
147
139
|
id: "dve_air",
|
|
@@ -226,7 +218,6 @@ export function InitVoxelData(data) {
|
|
|
226
218
|
},
|
|
227
219
|
...(data.substances || []),
|
|
228
220
|
];
|
|
229
|
-
SubstanceDataGenerator.generate(substances);
|
|
230
221
|
const voxels = [
|
|
231
222
|
{
|
|
232
223
|
id: "dve_air",
|
|
@@ -236,57 +227,24 @@ export function InitVoxelData(data) {
|
|
|
236
227
|
},
|
|
237
228
|
...data.voxels,
|
|
238
229
|
];
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
230
|
+
const voxelData = BuildTagAndPaletteData({
|
|
231
|
+
voxels,
|
|
232
|
+
voxelsOverrides: {
|
|
233
|
+
[VoxelTagIds.lightValue]: (value) => {
|
|
234
|
+
const v = value;
|
|
235
|
+
let sl = 0;
|
|
236
|
+
sl = lightData.setR(v[0], sl);
|
|
237
|
+
sl = lightData.setG(v[1], sl);
|
|
238
|
+
sl = lightData.setB(v[2], sl);
|
|
239
|
+
return sl;
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
substances,
|
|
243
|
+
materials,
|
|
252
244
|
});
|
|
253
|
-
VoxelDataGenerator.generate(voxels);
|
|
254
245
|
let models = GetModelData(data);
|
|
255
|
-
const voxelMaps = VoxelStructBuilder.getMaps();
|
|
256
|
-
const voxelStringMaps = MappedDataRegister.stringMaps.getSegment("voxel");
|
|
257
|
-
for (const key in voxelMaps.stringMaps) {
|
|
258
|
-
voxelStringMaps.add(key, voxelMaps.stringMaps[key]);
|
|
259
|
-
}
|
|
260
|
-
const voxelObjectMaps = MappedDataRegister.objectMaps.getSegment("voxel");
|
|
261
|
-
for (const key in voxelMaps.objectMaps) {
|
|
262
|
-
voxelObjectMaps.add(key, voxelMaps.objectMaps[key]);
|
|
263
|
-
}
|
|
264
|
-
const substanceMaps = SubstanceStructBuilder.getMaps();
|
|
265
|
-
const substanceStringMaps = MappedDataRegister.stringMaps.getSegment("substance");
|
|
266
|
-
for (const key in substanceMaps.stringMaps) {
|
|
267
|
-
substanceStringMaps.add(key, substanceMaps.stringMaps[key]);
|
|
268
|
-
}
|
|
269
|
-
const substanceObjectMaps = MappedDataRegister.objectMaps.getSegment("substance");
|
|
270
|
-
for (const key in substanceMaps.objectMaps) {
|
|
271
|
-
substanceObjectMaps.add(key, substanceMaps.objectMaps[key]);
|
|
272
|
-
}
|
|
273
246
|
return {
|
|
274
|
-
materials: {
|
|
275
|
-
palette: MaterialPalette.palette._palette,
|
|
276
|
-
},
|
|
277
247
|
models,
|
|
278
|
-
|
|
279
|
-
palette: VoxelDataGenerator.palette._palette,
|
|
280
|
-
nameToIdMap: VoxelDataGenerator.nameToIdMap,
|
|
281
|
-
idToNameMap: VoxelDataGenerator.idToNameMap,
|
|
282
|
-
...voxelMaps,
|
|
283
|
-
struct: VoxelStruct.initData,
|
|
284
|
-
index: VoxelStruct.voxelIndex,
|
|
285
|
-
},
|
|
286
|
-
substances: {
|
|
287
|
-
palette: SubstanceDataGenerator.palette._palette,
|
|
288
|
-
...substanceMaps,
|
|
289
|
-
struct: SubstanceStruct.initData,
|
|
290
|
-
},
|
|
248
|
+
...voxelData,
|
|
291
249
|
};
|
|
292
250
|
}
|