@divinevoxel/vlox 0.0.7 → 0.0.72

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.
Files changed (168) hide show
  1. package/Contexts/Base/Main/InitDataGenerator.js +0 -9
  2. package/Contexts/Base/Remote/DataSync.types.d.ts +0 -5
  3. package/Contexts/Base/Remote/InitDataSync.js +17 -31
  4. package/Init/StartConstructor.js +2 -4
  5. package/Init/StartWorld.js +0 -12
  6. package/Math/Indexing.d.ts +12 -3
  7. package/Math/Indexing.js +24 -15
  8. package/Mesher/Functions/CompactVoxelMesh.d.ts +1 -1
  9. package/Mesher/Functions/CompactVoxelMesh.js +3 -4
  10. package/Mesher/Functions/MeshSection.d.ts +1 -1
  11. package/Mesher/Functions/MeshSection.js +54 -60
  12. package/Mesher/Functions/MeshVoxel.js +20 -26
  13. package/Mesher/Geomtry/Buffers.d.ts +9 -8
  14. package/Mesher/Geomtry/Buffers.js +26 -58
  15. package/Mesher/Geomtry/Tools/MesherDataTools.d.ts +1 -1
  16. package/Mesher/Geomtry/Tools/MesherDataTools.js +1 -1
  17. package/Mesher/Geomtry/VoxelGeometryBuilder.js +107 -124
  18. package/Mesher/InitMesher.js +1 -10
  19. package/Mesher/InitTask.js +10 -4
  20. package/Mesher/Models/Common/BoundsFunctions.d.ts +1 -3
  21. package/Mesher/Models/Common/BoundsFunctions.js +0 -16
  22. package/Mesher/Models/Common/Calc/CalcConstants.js +14 -31
  23. package/Mesher/Models/Common/Calc/FaceDataCalc.d.ts +1 -7
  24. package/Mesher/Models/Common/Calc/FaceDataCalc.js +41 -50
  25. package/Mesher/Models/Nodes/Custom/Liquid/LiquidGeomtryNode.d.ts +1 -5
  26. package/Mesher/Models/Nodes/Custom/Liquid/LiquidGeomtryNode.js +30 -26
  27. package/Mesher/Models/Nodes/GeometryNode.d.ts +2 -4
  28. package/Mesher/Models/Nodes/GeometryNode.js +1 -2
  29. package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.d.ts +2 -6
  30. package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.js +37 -34
  31. package/Mesher/Models/Nodes/Ruled/QuadVoxelGeometryNode.d.ts +2 -6
  32. package/Mesher/Models/Nodes/Ruled/QuadVoxelGeometryNode.js +52 -51
  33. package/Mesher/Models/Nodes/Ruleless/RulelessBoxVoxelGeometryNode.d.ts +2 -6
  34. package/Mesher/Models/Nodes/Ruleless/RulelessBoxVoxelGeometryNode.js +18 -19
  35. package/Mesher/Models/Nodes/Ruleless/RulelessQuadVoxelGeometryNode.d.ts +2 -6
  36. package/Mesher/Models/Nodes/Ruleless/RulelessQuadVoxelGeometryNode.js +37 -40
  37. package/Mesher/Models/VoxelConstructor.d.ts +3 -4
  38. package/Mesher/Models/VoxelConstructor.js +23 -12
  39. package/Mesher/Models/{VoxelGeometryLookUp.d.ts → VoxelGeometryBuilderCacheSpace.d.ts} +8 -14
  40. package/Mesher/Models/{VoxelGeometryLookUp.js → VoxelGeometryBuilderCacheSpace.js} +49 -44
  41. package/Mesher/Models/VoxelModelConstructorRegister.js +3 -3
  42. package/Mesher/Tools/VoxelMeshBVHBuilder.d.ts +2 -9
  43. package/Mesher/Tools/VoxelMeshBVHBuilder.js +4 -16
  44. package/Mesher/Tools/VoxelMeshVertexStructCursor.d.ts +10 -0
  45. package/Mesher/Tools/VoxelMeshVertexStructCursor.js +10 -0
  46. package/Mesher/Tools/VoxelMesherDataTool.d.ts +8 -5
  47. package/Mesher/Tools/VoxelMesherDataTool.js +34 -13
  48. package/Models/Indexing/VoxelAOResultsIndex.d.ts +4 -4
  49. package/Models/Indexing/VoxelAOResultsIndex.js +15 -9
  50. package/Models/Indexing/VoxelFaceCullResultsIndex.d.ts +3 -3
  51. package/Models/Indexing/VoxelFaceCullResultsIndex.js +14 -9
  52. package/Models/Indexing/VoxelFaceTransparentResultsIndex.d.ts +1 -1
  53. package/Models/Indexing/VoxelFaceTransparentResultsIndex.js +1 -1
  54. package/Models/Rules/Functions/BuildRules.js +2 -2
  55. package/Tasks/IWG/Internal/Classes/Generator.js +1 -1
  56. package/Tasks/IWG/Internal/Functions/getSectorState.js +4 -7
  57. package/Tasks/IWG/Internal/Functions/runWorldUpdate.js +5 -6
  58. package/Tasks/IWG/Internal/IWGTasks.js +12 -21
  59. package/Tasks/Propagation/Flow/FlowManager.d.ts +0 -2
  60. package/Tasks/Propagation/Flow/FlowManager.js +86 -87
  61. package/Tasks/Propagation/Flow/WorldFlow.js +2 -3
  62. package/Tasks/Propagation/Illumanation/WorldRGB.js +1 -2
  63. package/Tasks/Update/InitTasks.d.ts +2 -1
  64. package/Tasks/Update/InitTasks.js +6 -6
  65. package/Tasks/Update/VoxelUpdate.js +15 -7
  66. package/Tasks/WorldGeneration/WorldGenBrush.js +1 -0
  67. package/Templates/Cursor/TemplateCursor.d.ts +1 -1
  68. package/Templates/Cursor/TemplateCursor.js +1 -1
  69. package/Templates/Functions/CreateTemplate.js +1 -1
  70. package/Templates/VoxelTemplate.js +6 -8
  71. package/Tools/Brush/Brush.d.ts +0 -2
  72. package/Tools/Brush/Brush.js +5 -6
  73. package/{Data/Cursor → Tools}/DataCursor.interface.d.ts +1 -1
  74. package/Util/Binary/BitArray.d.ts +4 -0
  75. package/Util/Binary/BitArray.js +16 -0
  76. package/Util/StringPalette.d.ts +1 -0
  77. package/Util/StringPalette.js +8 -0
  78. package/Voxels/Cursor/VoxelCursor.d.ts +6 -6
  79. package/Voxels/Cursor/VoxelCursor.interface.d.ts +10 -15
  80. package/Voxels/Cursor/VoxelCursor.interface.js +30 -50
  81. package/Voxels/Cursor/VoxelCursor.js +13 -12
  82. package/Voxels/Cursor/VoxelLightData.d.ts +3 -4
  83. package/Voxels/Cursor/VoxelLightData.js +8 -7
  84. package/Voxels/Data/VoxelPalettesRegister.d.ts +13 -0
  85. package/Voxels/Data/VoxelPalettesRegister.js +17 -0
  86. package/Voxels/Data/VoxelTag.types.d.ts +56 -0
  87. package/Voxels/Data/VoxelTag.types.js +23 -0
  88. package/Voxels/{State → Data}/VoxelTagStates.d.ts +2 -2
  89. package/Voxels/{State → Data}/VoxelTagStates.js +5 -5
  90. package/Voxels/Data/VoxelTagsRegister.d.ts +9 -0
  91. package/Voxels/Data/VoxelTagsRegister.js +32 -0
  92. package/Voxels/Functions/BuildStateData.js +3 -3
  93. package/Voxels/Functions/BuildTagAndPaletteData.d.ts +13 -0
  94. package/Voxels/Functions/BuildTagAndPaletteData.js +57 -0
  95. package/Voxels/Indexes/VoxelIndex.js +3 -3
  96. package/Voxels/InitVoxelData.js +20 -61
  97. package/Voxels/State/Schema/StateSchema.d.ts +1 -1
  98. package/Voxels/Types/Voxel.types.d.ts +2 -42
  99. package/Voxels/Types/Voxel.types.js +0 -15
  100. package/Voxels/Types/VoxelModelCompiledData.types.d.ts +11 -13
  101. package/Voxels/Types/VoxelSubstances.types.d.ts +2 -15
  102. package/Voxels/Types/VoxelSubstances.types.js +1 -9
  103. package/World/Archive/Functions/ArchiveArea.js +2 -6
  104. package/World/Archive/Functions/ArchiveSector.js +14 -28
  105. package/World/Archive/Functions/ImportSector.js +27 -34
  106. package/World/Cursor/SectionCursor.d.ts +2 -1
  107. package/World/Cursor/SectionCursor.js +8 -2
  108. package/World/Cursor/SectorCursor.d.ts +2 -1
  109. package/World/Cursor/SectorCursor.js +5 -2
  110. package/World/Cursor/WorldCursor.d.ts +1 -1
  111. package/World/Cursor/WorldCursor.js +6 -2
  112. package/World/Cursor/WorldVoxelCursor.d.ts +7 -7
  113. package/World/Cursor/WorldVoxelCursor.js +20 -24
  114. package/World/Section/Section.d.ts +20 -8
  115. package/World/Section/Section.js +65 -9
  116. package/World/Sector/Sector.d.ts +13 -6
  117. package/World/Sector/Sector.js +30 -9
  118. package/World/Sector/SectorHeightMap.js +1 -3
  119. package/World/Sector/SectorState.d.ts +13 -0
  120. package/World/Sector/SectorState.js +15 -0
  121. package/World/WorldSpaces.d.ts +2 -0
  122. package/World/WorldSpaces.js +7 -1
  123. package/package.json +1 -1
  124. package/Data/Register/MappedDataRegister.d.ts +0 -5
  125. package/Data/Register/MappedDataRegister.js +0 -9
  126. package/Data/Register/MappedRegisterBase.d.ts +0 -14
  127. package/Data/Register/MappedRegisterBase.js +0 -50
  128. package/Data/Structs/StructBuilder.d.ts +0 -34
  129. package/Data/Structs/StructBuilder.js +0 -157
  130. package/Data/Structs/StructBuilder.types.d.ts +0 -30
  131. package/Data/Structs/StructBuilder.types.js +0 -1
  132. package/Tools/Data/SubstanceDataTool.d.ts +0 -13
  133. package/Tools/Data/SubstanceDataTool.js +0 -51
  134. package/Voxels/Palettes/MaterialPalette.d.ts +0 -9
  135. package/Voxels/Palettes/MaterialPalette.js +0 -11
  136. package/Voxels/Palettes/SubstancePalette.d.ts +0 -9
  137. package/Voxels/Palettes/SubstancePalette.js +0 -11
  138. package/Voxels/Palettes/VoxelPalette.d.ts +0 -11
  139. package/Voxels/Palettes/VoxelPalette.js +0 -15
  140. package/Voxels/Segments/MaterialDataGenerator.d.ts +0 -6
  141. package/Voxels/Segments/MaterialDataGenerator.js +0 -12
  142. package/Voxels/Segments/SubstanceDataGenerator.d.ts +0 -6
  143. package/Voxels/Segments/SubstanceDataGenerator.js +0 -35
  144. package/Voxels/Segments/VoxelDataGenerator.d.ts +0 -10
  145. package/Voxels/Segments/VoxelDataGenerator.js +0 -56
  146. package/Voxels/Structs/Builder/SubstanceStructBuilder.d.ts +0 -2
  147. package/Voxels/Structs/Builder/SubstanceStructBuilder.js +0 -42
  148. package/Voxels/Structs/Builder/VoxelStructBuilder.d.ts +0 -2
  149. package/Voxels/Structs/Builder/VoxelStructBuilder.js +0 -68
  150. package/Voxels/Structs/SubstanceStruct.d.ts +0 -17
  151. package/Voxels/Structs/SubstanceStruct.js +0 -17
  152. package/Voxels/Structs/VoxelStruct.d.ts +0 -27
  153. package/Voxels/Structs/VoxelStruct.js +0 -29
  154. package/World/Section/SectionHeightMap.d.ts +0 -10
  155. package/World/Section/SectionHeightMap.js +0 -39
  156. package/World/Section/SectionStruct.d.ts +0 -8
  157. package/World/Section/SectionStruct.js +0 -29
  158. package/World/Section/SectionStructProperties.d.ts +0 -10
  159. package/World/Section/SectionStructProperties.js +0 -11
  160. package/World/Sector/SectorStruct.d.ts +0 -1
  161. package/World/Sector/SectorStruct.js +0 -46
  162. package/World/Sector/SectorStructIds.d.ts +0 -13
  163. package/World/Sector/SectorStructIds.js +0 -14
  164. /package/{Data/Cursor → Tools}/DataCursor.interface.js +0 -0
  165. /package/{Data/Functions → Util/Binary}/Palettes.d.ts +0 -0
  166. /package/{Data/Functions → Util/Binary}/Palettes.js +0 -0
  167. /package/Voxels/{VoxelLevelReader.d.ts → Cursor/VoxelLevelReader.d.ts} +0 -0
  168. /package/Voxels/{VoxelLevelReader.js → Cursor/VoxelLevelReader.js} +0 -0
@@ -81,11 +81,12 @@ export class VoxelLightData {
81
81
  return 0;
82
82
  return (sl & ~0xfff0) | (value << 4);
83
83
  }
84
- decodeLightFromVoxelData(voxelData) {
85
- return (voxelData & (0xffff << 0)) >> 0;
86
- }
87
- encodeLightIntoVoxelData(voxelData, encodedLight) {
88
- return (voxelData & ~(0xffff << 0)) | (encodedLight << 0);
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
- getLightValues(value) {
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
- getLightValuesToRef(value, values) {
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,13 @@
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
+ static loadInVoxel(voxelPalette: string[], nameToIdMap: Record<string, string>, idToNameMap: Record<string, string>): void;
9
+ static voxelName: {
10
+ getId: (name: string) => string;
11
+ getName: (id: string) => string;
12
+ };
13
+ }
@@ -0,0 +1,17 @@
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
+ static loadInVoxel(voxelPalette, nameToIdMap, idToNameMap) {
9
+ this.voxels = new StringPalette(voxelPalette);
10
+ this.voxelNametoIdMap = new Map(Object.entries(nameToIdMap));
11
+ this.voxelIdToNameMap = new Map(Object.entries(idToNameMap));
12
+ }
13
+ static voxelName = {
14
+ getId: (name) => this.voxelNametoIdMap.get(name),
15
+ getName: (id) => this.voxelIdToNameMap.get(id),
16
+ };
17
+ }
@@ -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 "./Schema/StateSchema";
2
- import { StateTreeReader } from "./StateTreeReader";
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 { VoxelPalette } from "../Palettes/VoxelPalette";
2
- import { StateSchema } from "./Schema/StateSchema";
3
- import { StateTreeReader } from "./StateTreeReader";
4
- import { SchemaRegister } from "./SchemaRegister";
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(VoxelPalette.ids.getStringId(index))));
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, 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
+ VoxelSubstanceTagIdds.parent,
18
+ VoxelSubstanceTagIdds.isSolid,
19
+ VoxelSubstanceTagIdds.isTransparent,
20
+ VoxelSubstanceTagIdds.isLiquid,
21
+ VoxelSubstanceTagIdds.flowRate,
22
+ VoxelSubstanceTagIdds.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
3
  import { VoxelModelManager } from "../../Models/Rules/VoxelModelManager";
4
- import { VoxelTagStates } from "../State/VoxelTagStates";
5
- import { VoxelPalette } from "../Palettes/VoxelPalette";
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)
@@ -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(VoxelPalette.ids.getNumberId(voxelId), tag.tagId, schema, tag.tree, tag.treePalette);
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,57 @@
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
+ if (voxel.name) {
8
+ VoxelPalettesRegister.voxelIdToNameMap.set(voxel.id, voxel.name || "");
9
+ VoxelPalettesRegister.voxelNametoIdMap.set(voxel.name || "", voxel.id);
10
+ }
11
+ for (const tag of VoxelTagsRegister.IncludedVoxelTags) {
12
+ if (voxel.properties[tag] === undefined) {
13
+ tags[tag] = VoxelTagsRegister.VoxelTagDefaults[tag] || false;
14
+ continue;
15
+ }
16
+ if (props?.voxelsOverrides?.[tag]) {
17
+ tags[tag] = props.voxelsOverrides[tag](voxel.properties[tag]);
18
+ continue;
19
+ }
20
+ tags[tag] = voxel.properties[tag];
21
+ }
22
+ VoxelTagsRegister.VoxelTags[voxelId] = tags;
23
+ }
24
+ for (const substance of props.substances) {
25
+ const tags = {};
26
+ const substanceId = VoxelPalettesRegister.substance.register(substance.id);
27
+ for (const tag of VoxelTagsRegister.IncludedSubstnacesTags) {
28
+ if (substance.properties[tag] === undefined) {
29
+ tags[tag] =
30
+ VoxelTagsRegister.SubstanceStagDefaults[tag] || false;
31
+ continue;
32
+ }
33
+ if (props?.substancesOverrides?.[tag]) {
34
+ tags[tag] = props.substancesOverrides[tag](substance.properties[tag]);
35
+ continue;
36
+ }
37
+ tags[tag] = substance.properties[tag];
38
+ }
39
+ VoxelTagsRegister.SubstanceStags[substanceId] = tags;
40
+ }
41
+ for (const material of props.materials) {
42
+ VoxelPalettesRegister.material.register(material.id);
43
+ }
44
+ return {
45
+ data: {
46
+ palette: VoxelPalettesRegister.voxels._palette,
47
+ tags: VoxelTagsRegister.VoxelTags,
48
+ idToNameMap: [...VoxelPalettesRegister.voxelIdToNameMap.entries()],
49
+ nameToIdMap: [...VoxelPalettesRegister.voxelNametoIdMap.entries()],
50
+ },
51
+ substances: {
52
+ tags: VoxelTagsRegister.SubstanceStags,
53
+ palette: VoxelPalettesRegister.substance._palette,
54
+ },
55
+ materials: { palette: VoxelPalettesRegister.material._palette },
56
+ };
57
+ }
@@ -1,6 +1,6 @@
1
1
  import { PaintVoxelData } from "../Types/Voxel.types";
2
2
  import { SchemaRegister } from "../State/SchemaRegister";
3
- import { VoxelPalette } from "../Palettes/VoxelPalette";
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(VoxelPalette.ids.getStringId(id));
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) {
@@ -5,25 +5,17 @@ import { diagonalFlatPanelEastWest, diagonalFlatPanelWestEast, thinPanelDown, th
5
5
  import { stair } from "../Models/Defaults/StairVoxelModel";
6
6
  import { liquidGeometry, liquidModel, } from "../Models/Defaults/LiquidVoxelModel";
7
7
  import { VoxelModelManager } from "../Models/Rules/VoxelModelManager";
8
- import { VoxelStructIds } from "./Types/Voxel.types";
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 "../Voxels/State/VoxelTagStates";
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 { MaterialDataGenerator } from "./Segments/MaterialDataGenerator";
19
- import { SubstanceDataGenerator } from "./Segments/SubstanceDataGenerator";
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;
@@ -105,6 +97,7 @@ function GetModelData(data) {
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,
@@ -123,6 +116,7 @@ function GetModelData(data) {
123
116
  export function InitVoxelData(data) {
124
117
  const lightData = new VoxelLightData();
125
118
  const voxelIndex = new VoxelIndex(data.voxels);
119
+ console.warn(voxelIndex, voxelIndex.dataMap);
126
120
  const materials = [
127
121
  { id: "dve_solid", properties: {} },
128
122
  { id: "dve_flora", properties: {} },
@@ -141,7 +135,6 @@ export function InitVoxelData(data) {
141
135
  },
142
136
  ...(data.materials || []),
143
137
  ];
144
- MaterialDataGenerator.generate(materials);
145
138
  const substances = [
146
139
  {
147
140
  id: "dve_air",
@@ -226,7 +219,6 @@ export function InitVoxelData(data) {
226
219
  },
227
220
  ...(data.substances || []),
228
221
  ];
229
- SubstanceDataGenerator.generate(substances);
230
222
  const voxels = [
231
223
  {
232
224
  id: "dve_air",
@@ -236,57 +228,24 @@ export function InitVoxelData(data) {
236
228
  },
237
229
  ...data.voxels,
238
230
  ];
239
- VoxelDataGenerator.overrides.set(VoxelStructIds.lightValue, (tags, value) => {
240
- const v = value;
241
- let sl = 0;
242
- sl = lightData.setR(v[0], sl);
243
- sl = lightData.setG(v[1], sl);
244
- sl = lightData.setB(v[2], sl);
245
- tags.setProperty(VoxelStructIds.lightValue, sl);
246
- });
247
- VoxelDataGenerator.overrides.set(VoxelStructIds.renderedMaterial, (tags, value) => {
248
- tags.setProperty(VoxelStructIds.renderedMaterial, MaterialDataGenerator.palette._map[value]);
249
- });
250
- VoxelDataGenerator.overrides.set(VoxelStructIds.substance, (tags, value) => {
251
- tags.setProperty(VoxelStructIds.substance, SubstanceDataGenerator.palette._map[value]);
231
+ const voxelData = BuildTagAndPaletteData({
232
+ voxels,
233
+ voxelsOverrides: {
234
+ [VoxelTagIds.lightValue]: (value) => {
235
+ const v = value;
236
+ let sl = 0;
237
+ sl = lightData.setR(v[0], sl);
238
+ sl = lightData.setG(v[1], sl);
239
+ sl = lightData.setB(v[2], sl);
240
+ return sl;
241
+ },
242
+ },
243
+ substances,
244
+ materials,
252
245
  });
253
- VoxelDataGenerator.generate(voxels);
254
246
  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
247
  return {
274
- materials: {
275
- palette: MaterialPalette.palette._palette,
276
- },
277
248
  models,
278
- data: {
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
- },
249
+ ...voxelData,
291
250
  };
292
251
  }
@@ -1,7 +1,7 @@
1
1
  import { ShapeStateRelationsNode } from "./ShapeStateRelationsNode";
2
2
  import { BinarySchemaNode } from "./BinarySchemaNode";
3
3
  import { VoxelModelStateSchemaData } from "../State.types";
4
- import { DataCursorInterface } from "../../../Data/Cursor/DataCursor.interface";
4
+ import { DataCursorInterface } from "../../../Tools/DataCursor.interface";
5
5
  import { Vector3Like } from "@amodx/math";
6
6
  import { VoxelCursorInterface } from "../../Cursor/VoxelCursor.interface";
7
7
  export declare class StateSchema {
@@ -1,5 +1,6 @@
1
1
  import { TextureId } from "../../Textures/index";
2
2
  import { VoxelModelConstructorData } from "../../Models/VoxelModel.types";
3
+ import { VoxelTags } from "../Data/VoxelTag.types";
3
4
  export type VoxelNamedStateData = {
4
5
  id: string;
5
6
  name?: string;
@@ -44,49 +45,8 @@ export type RawVoxelData = [
44
45
  /**The secondary id of the voxel */
45
46
  secondary: number
46
47
  ];
47
- export declare enum VoxelStructIds {
48
- substance = "dve_substance",
49
- renderedMaterial = "dve_rendered_material",
50
- voxelMaterial = "dve_voxel_material",
51
- hardness = "dve_hardness",
52
- colliderID = "dve_collider_id",
53
- checkCollisions = "dve_check_collisions",
54
- isLightSource = "dve_is_light_source",
55
- noAO = "dve_no_ao",
56
- isTransparent = "dve_is_transparent",
57
- lightValue = "dve_light_value",
58
- isRich = "dve_is_rich",
59
- canHaveSecondary = "dve_can_have_secondary"
60
- }
61
- interface VoxelProperties {
48
+ interface VoxelProperties extends Partial<VoxelTags> {
62
49
  [key: string]: any;
63
- /** The material used to render the voxel. Used by the engine to assign meshes to the proper material. */
64
- [VoxelStructIds.renderedMaterial]?: string;
65
- /** A description of the material used for the voxel. Not used by the engine directly. */
66
- [VoxelStructIds.voxelMaterial]?: string;
67
- /** Specifies the substance of the voxel.
68
- * The voxel will inherit properties from the substance and change how it acts in the world.
69
- * Properties include being solid or liquid.
70
- * */
71
- [VoxelStructIds.substance]?: string;
72
- /** Indicates whether the voxel is a light source. */
73
- [VoxelStructIds.isLightSource]?: boolean;
74
- /** Indicates if the voxel lets light through */
75
- [VoxelStructIds.isTransparent]?: boolean;
76
- /** Disables ambient occlusion for this voxel if set to true. */
77
- [VoxelStructIds.noAO]?: boolean;
78
- /** Defines the light value emitted by the voxel (r, g, z). */
79
- [VoxelStructIds.lightValue]?: [r: number, g: number, z: number];
80
- /** The collider ID for the voxel, used for collision detection. */
81
- [VoxelStructIds.colliderID]?: string;
82
- /** Specifies if the voxel participates in collision checks. */
83
- [VoxelStructIds.checkCollisions]?: boolean;
84
- /** Indicates if the voxel can have a secondary voxel. */
85
- [VoxelStructIds.canHaveSecondary]?: boolean;
86
- /** The hardness level of the voxel, affecting how it is broken or interacted with. */
87
- [VoxelStructIds.hardness]?: number;
88
- /** Marks the voxel as "rich" for specialized interactions or rendering. */
89
- [VoxelStructIds.isRich]?: boolean;
90
50
  /** Named states associated with the voxel. */
91
51
  dve_named_states?: VoxelNamedStateData[];
92
52
  /** Model data used to construct the voxel's appearance. */
@@ -17,18 +17,3 @@ export class PaintVoxelData {
17
17
  this.secondaryVoxelId = secondaryVoxelId;
18
18
  }
19
19
  }
20
- export var VoxelStructIds;
21
- (function (VoxelStructIds) {
22
- VoxelStructIds["substance"] = "dve_substance";
23
- VoxelStructIds["renderedMaterial"] = "dve_rendered_material";
24
- VoxelStructIds["voxelMaterial"] = "dve_voxel_material";
25
- VoxelStructIds["hardness"] = "dve_hardness";
26
- VoxelStructIds["colliderID"] = "dve_collider_id";
27
- VoxelStructIds["checkCollisions"] = "dve_check_collisions";
28
- VoxelStructIds["isLightSource"] = "dve_is_light_source";
29
- VoxelStructIds["noAO"] = "dve_no_ao";
30
- VoxelStructIds["isTransparent"] = "dve_is_transparent";
31
- VoxelStructIds["lightValue"] = "dve_light_value";
32
- VoxelStructIds["isRich"] = "dve_is_rich";
33
- VoxelStructIds["canHaveSecondary"] = "dve_can_have_secondary";
34
- })(VoxelStructIds || (VoxelStructIds = {}));
@@ -5,29 +5,26 @@ import { VoxelFaceTransparentResultsIndexData } from "../../Models/Indexing/Voxe
5
5
  import { VoxelModelStateSchemaData, StateLogicStatement } from "../State/State.types";
6
6
  import { VoxelGeometryData, VoxelGeometryNodes } from "../../Models/VoxelModel.types";
7
7
  import { VoxelEffectSyncData } from "../Effects/VoxelEffects.types";
8
- import { VoxelTagStatesData } from "../State/VoxelTagStates";
9
- import { BinaryStructData } from "@amodx/binary";
10
- export type CompiledVoxelData = {
11
- models: FinalCompiledVoxelModelData;
8
+ import { VoxelTagStatesData } from "../Data/VoxelTagStates";
9
+ import { VoxelSubstanceTags, VoxelTags } from "../Data/VoxelTag.types";
10
+ export type CompiledVoxelTagAndPaletteData = {
12
11
  data: {
13
- struct: BinaryStructData;
14
- index: Uint16Array;
12
+ tags: VoxelTags[];
15
13
  palette: string[];
16
- nameToIdMap: Record<string, string>;
17
- idToNameMap: Record<string, string>;
18
- stringMaps: Record<string, string[]>;
19
- objectMaps: Record<string, any[]>;
14
+ nameToIdMap: [string, string][];
15
+ idToNameMap: [string, string][];
20
16
  };
21
17
  substances: {
22
- struct: BinaryStructData;
18
+ tags: VoxelSubstanceTags[];
23
19
  palette: string[];
24
- stringMaps: Record<string, string[]>;
25
- objectMaps: Record<string, any[]>;
26
20
  };
27
21
  materials: {
28
22
  palette: string[];
29
23
  };
30
24
  };
25
+ export type CompiledVoxelData = {
26
+ models: FinalCompiledVoxelModelData;
27
+ } & CompiledVoxelTagAndPaletteData;
31
28
  export interface CompiledVoxelGeometryNodes {
32
29
  node: VoxelGeometryNodes;
33
30
  tranform: VoxelGeometryTransform;
@@ -77,6 +74,7 @@ export interface CompiledVoxelModelData {
77
74
  }
78
75
  export interface CompiledVoxelModelInputData {
79
76
  id: string;
77
+ materialId: string;
80
78
  modelId: string;
81
79
  transparentFaceIndex: VoxelFaceTransparentResultsIndexData;
82
80
  modSchema: VoxelModelStateSchemaData[];
@@ -1,19 +1,6 @@
1
- export declare enum SubstanceStructIds {
2
- parent = "dve_parent_substance",
3
- isSolid = "dve_is_solid",
4
- isTransparent = "dve_is_transparent",
5
- isLiquid = "dve_is_liquid",
6
- flowRate = "dve_flow_rate",
7
- isWindAffected = "dve_is_wind_affected"
8
- }
9
- export interface VoxelSubstanceDataProperties {
1
+ import { VoxelSubstanceTags } from "../Data/VoxelTag.types";
2
+ export interface VoxelSubstanceDataProperties extends Partial<VoxelSubstanceTags> {
10
3
  [key: string]: any;
11
- [SubstanceStructIds.parent]?: string;
12
- [SubstanceStructIds.isTransparent]?: boolean;
13
- [SubstanceStructIds.isSolid]?: boolean;
14
- [SubstanceStructIds.isLiquid]?: boolean;
15
- [SubstanceStructIds.flowRate]?: number;
16
- [SubstanceStructIds.isWindAffected]?: boolean;
17
4
  }
18
5
  export type VoxelSubstanceData = {
19
6
  id: string;
@@ -1,9 +1 @@
1
- export var SubstanceStructIds;
2
- (function (SubstanceStructIds) {
3
- SubstanceStructIds["parent"] = "dve_parent_substance";
4
- SubstanceStructIds["isSolid"] = "dve_is_solid";
5
- SubstanceStructIds["isTransparent"] = "dve_is_transparent";
6
- SubstanceStructIds["isLiquid"] = "dve_is_liquid";
7
- SubstanceStructIds["flowRate"] = "dve_flow_rate";
8
- SubstanceStructIds["isWindAffected"] = "dve_is_wind_affected";
9
- })(SubstanceStructIds || (SubstanceStructIds = {}));
1
+ export {};