@divinevoxel/vlox 0.0.72 → 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.
Files changed (174) hide show
  1. package/Contexts/Render/DivineVoxelEngineRender.d.ts +1 -1
  2. package/Contexts/World/DivineVoxelEngineWorld.d.ts +1 -1
  3. package/Init/StartConstructor.js +6 -4
  4. package/Init/StartWorld.d.ts +1 -1
  5. package/Mesher/Functions/CompactVoxelMesh.d.ts +2 -2
  6. package/Mesher/Functions/CompactVoxelMesh.js +1 -1
  7. package/Mesher/Functions/MeshSection.js +20 -8
  8. package/Mesher/Functions/MeshTexture.d.ts +1 -1
  9. package/Mesher/Functions/MeshTexture.js +3 -4
  10. package/Mesher/Geomtry/Primitives/QuadVertexData.d.ts +12 -10
  11. package/Mesher/Geomtry/Primitives/QuadVertexData.js +49 -56
  12. package/Mesher/Geomtry/VoxelGeometryBuilder.d.ts +2 -2
  13. package/Mesher/Geomtry/VoxelGeometryBuilder.js +2 -2
  14. package/Mesher/Geomtry/VoxelMesh.d.ts +1 -1
  15. package/Mesher/Geomtry/VoxelMesh.js +2 -2
  16. package/Mesher/Geomtry/index.d.ts +0 -1
  17. package/Mesher/Geomtry/index.js +0 -1
  18. package/Mesher/InitMesher.js +1 -1
  19. package/Mesher/InitTask.js +4 -22
  20. package/Mesher/Models/Common/Calc/FaceDataCalc.d.ts +2 -2
  21. package/Mesher/Models/Common/Calc/FaceDataCalc.js +37 -30
  22. package/Mesher/Models/Nodes/Custom/Liquid/FlowGradient.d.ts +2 -2
  23. package/Mesher/Models/Nodes/Custom/Liquid/FlowGradient.js +1 -1
  24. package/Mesher/Models/Nodes/Custom/Liquid/LiquidGeomtryNode.js +11 -17
  25. package/Mesher/Models/Nodes/GeometryNode.d.ts +2 -2
  26. package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.d.ts +1 -0
  27. package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.js +24 -12
  28. package/Mesher/{Tools → Models/Protocols}/OutlinedVoxelTool.d.ts +1 -1
  29. package/Mesher/{Tools → Models/Protocols}/OutlinedVoxelTool.js +1 -1
  30. package/Mesher/Models/RenderedMaterials.d.ts +6 -0
  31. package/Mesher/{RenderedMaterials.js → Models/RenderedMaterials.js} +2 -2
  32. package/Mesher/Models/VoxelConstructor.d.ts +3 -3
  33. package/Mesher/Models/VoxelGeometryBuilderCacheSpace.d.ts +1 -3
  34. package/Mesher/Models/VoxelGeometryBuilderCacheSpace.js +0 -23
  35. package/Mesher/{Tools/VoxelMesherDataTool.d.ts → Models/VoxelModelBuilder.d.ts} +4 -5
  36. package/Mesher/{Tools/VoxelMesherDataTool.js → Models/VoxelModelBuilder.js} +11 -7
  37. package/Models/Defaults/CubeVoxelGeometry.js +4 -0
  38. package/Models/Defaults/CubeVoxelModels.js +344 -344
  39. package/Models/Defaults/LiquidVoxelModel.js +2 -2
  40. package/Models/Defaults/PanelVoxelModels.js +432 -432
  41. package/Models/Defaults/StairVoxelModel.js +576 -576
  42. package/Models/Examples.js +469 -456
  43. package/Models/Rules/Functions/BuildFinalInputs.js +9 -7
  44. package/Models/Rules/Functions/BuildGeomtryInputs.js +8 -5
  45. package/Models/Rules/Functions/BuildRules.js +2 -2
  46. package/Models/Rules/{VoxelModelManager.d.ts → VoxelModelRuleBuilderRegister.d.ts} +1 -1
  47. package/Models/Rules/VoxelModelRuleBuilderRegister.js +178 -0
  48. package/Models/VoxelModel.types.d.ts +14 -5
  49. package/Renderer/Classes/SectorMesh.d.ts +3 -4
  50. package/Renderer/Classes/SectorMesh.js +6 -11
  51. package/Renderer/InitTasks.js +6 -7
  52. package/Renderer/MeshManager.js +2 -2
  53. package/Renderer/MeshRegister.js +2 -1
  54. package/Settings/EngineSettings.d.ts +1 -1
  55. package/Settings/EngineSettings.js +3 -5
  56. package/Settings/EngineSettings.types.d.ts +17 -18
  57. package/Settings/EngineSettings.types.js +16 -15
  58. package/Tasks/IWG/IWG.d.ts +2 -1
  59. package/Tasks/IWG/IWG.js +9 -3
  60. package/Tasks/IWG/Internal/Classes/BuildQueue.d.ts +11 -0
  61. package/Tasks/IWG/Internal/Classes/BuildQueue.js +49 -0
  62. package/Tasks/IWG/Internal/Classes/Generator.d.ts +6 -1
  63. package/Tasks/IWG/Internal/Classes/Generator.js +13 -1
  64. package/Tasks/IWG/Internal/Classes/IWGTaskBase.js +2 -2
  65. package/Tasks/IWG/Internal/Functions/runBuildUpdate.js +21 -2
  66. package/Tasks/IWG/Internal/IWGTasks.d.ts +0 -4
  67. package/Tasks/IWG/Internal/IWGTasks.js +0 -10
  68. package/Tasks/IWG/Internal/IWGTools.d.ts +1 -1
  69. package/Tasks/IWG/Procedures/SaveAllSectors.js +2 -0
  70. package/Tasks/Update/UpdateTask.d.ts +3 -1
  71. package/Tasks/Update/UpdateTask.js +28 -2
  72. package/Tasks/Update/VoxelUpdate.js +6 -0
  73. package/Tasks/WorldGeneration/WorldGenBrush.js +1 -1
  74. package/Templates/Cursor/TemplateCursor.d.ts +2 -2
  75. package/Templates/Cursor/TemplateCursor.js +1 -2
  76. package/Templates/VoxelTemplates.types.d.ts +1 -1
  77. package/Textures/Classes/CompiledTexture.d.ts +18 -0
  78. package/Textures/Classes/CompiledTexture.js +50 -0
  79. package/Textures/Classes/CompiledTextureAnimation.d.ts +12 -0
  80. package/Textures/Classes/CompiledTextureAnimation.js +27 -0
  81. package/Textures/Classes/TextureAnimationTexture.d.ts +10 -0
  82. package/Textures/Classes/TextureAnimationTexture.js +32 -0
  83. package/Textures/Functions/BuildTextureData.d.ts +10 -0
  84. package/Textures/Functions/BuildTextureData.js +205 -0
  85. package/Textures/Texture.types.d.ts +50 -64
  86. package/Textures/TextureManager.d.ts +8 -19
  87. package/Textures/TextureManager.js +28 -166
  88. package/Tools/Brush/Brush.d.ts +1 -1
  89. package/Tools/Brush/Brush.js +39 -7
  90. package/Util/Binary/BinaryArrays.d.ts +6 -0
  91. package/Util/Binary/BinaryArrays.js +25 -0
  92. package/Util/Binary/BinaryBuffer.d.ts +29 -0
  93. package/Util/Binary/BinaryBuffer.js +130 -0
  94. package/Util/Binary/{BitArray.d.ts → BinaryFunctions.d.ts} +1 -2
  95. package/Util/Binary/BinaryFunctions.js +11 -0
  96. package/Voxels/Cursor/DataCursor.interface.d.ts +5 -0
  97. package/Voxels/Cursor/VoxelCursor.interface.d.ts +1 -1
  98. package/Voxels/Cursor/VoxelCursor.interface.js +8 -11
  99. package/Voxels/Data/VoxelPalettesRegister.d.ts +0 -5
  100. package/Voxels/Data/VoxelPalettesRegister.js +0 -9
  101. package/Voxels/Data/VoxelTagsRegister.js +7 -7
  102. package/Voxels/Functions/BuildStateData.js +9 -9
  103. package/Voxels/Functions/BuildTagAndPaletteData.js +2 -4
  104. package/Voxels/InitVoxelData.js +12 -13
  105. package/Voxels/State/Schema/StateSchema.d.ts +1 -1
  106. package/Voxels/Types/Voxel.types.d.ts +18 -0
  107. package/Voxels/Types/Voxel.types.js +6 -2
  108. package/World/Archive/Archive.types.d.ts +38 -34
  109. package/World/Archive/Functions/ArchiveArea.js +16 -24
  110. package/World/Archive/Functions/ArchiveSector.js +477 -192
  111. package/World/Archive/Functions/ImportSector.d.ts +3 -3
  112. package/World/Archive/Functions/ImportSector.js +202 -141
  113. package/World/Archive/Functions/Shared.d.ts +6 -0
  114. package/World/Archive/Functions/Shared.js +75 -0
  115. package/World/Archive/InitTasks.js +30 -13
  116. package/World/Cursor/SectionCursor.d.ts +2 -2
  117. package/World/Cursor/SectionCursor.js +2 -3
  118. package/World/Cursor/SectorCursor.d.ts +2 -2
  119. package/World/Cursor/SectorCursor.js +1 -2
  120. package/World/Cursor/WorldCursor.d.ts +2 -2
  121. package/World/Cursor/WorldCursor.js +1 -2
  122. package/World/Cursor/WorldVoxelCursor.js +1 -0
  123. package/World/InitTasks.d.ts +1 -1
  124. package/World/Lock/WorldLock.d.ts +1 -1
  125. package/World/Section/Section.d.ts +12 -16
  126. package/World/Section/Section.js +62 -20
  127. package/World/Section/SectionState.d.ts +10 -0
  128. package/World/Section/SectionState.js +11 -0
  129. package/World/Sector/Sector.d.ts +14 -6
  130. package/World/Sector/Sector.js +67 -17
  131. package/World/Sector/SectorHeightMap.js +2 -2
  132. package/World/Sector/SectorState.d.ts +14 -6
  133. package/World/Sector/SectorState.js +28 -15
  134. package/World/Types/WorldStorage.interface.js +1 -0
  135. package/World/WorldRegister.d.ts +4 -0
  136. package/World/WorldRegister.js +15 -3
  137. package/World/WorldSpaces.d.ts +4 -0
  138. package/World/WorldSpaces.js +19 -6
  139. package/package.json +1 -1
  140. package/Mesher/Functions/CompactMesh.d.ts +0 -2
  141. package/Mesher/Functions/CompactMesh.js +0 -42
  142. package/Mesher/Geomtry/GeometryNormals.d.ts +0 -10
  143. package/Mesher/Geomtry/GeometryNormals.js +0 -52
  144. package/Mesher/Geomtry/MeshData.types.d.ts +0 -13
  145. package/Mesher/Geomtry/MeshData.types.js +0 -6
  146. package/Mesher/Geomtry/Tools/MesherDataTools.d.ts +0 -7
  147. package/Mesher/Geomtry/Tools/MesherDataTools.js +0 -12
  148. package/Mesher/Geomtry/Tools/index.d.ts +0 -1
  149. package/Mesher/Geomtry/Tools/index.js +0 -1
  150. package/Mesher/RenderedMaterials.d.ts +0 -6
  151. package/Models/Rules/VoxelModelManager.js +0 -82
  152. package/Textures/TextureAnimations.d.ts +0 -4
  153. package/Textures/TextureAnimations.js +0 -35
  154. package/Textures/TextureArray.d.ts +0 -47
  155. package/Textures/TextureArray.js +0 -202
  156. package/Textures/TextureBuilder.d.ts +0 -13
  157. package/Textures/TextureBuilder.js +0 -120
  158. package/Textures/TextureRegister.d.ts +0 -9
  159. package/Textures/TextureRegister.js +0 -28
  160. package/Tools/DataCursor.interface.d.ts +0 -5
  161. package/Tools/DataCursor.interface.js +0 -2
  162. package/Util/Binary/BitArray.js +0 -16
  163. package/World/Structs/WorldDataStructProperties.d.ts +0 -8
  164. package/World/Structs/WorldDataStructProperties.js +0 -9
  165. /package/Mesher/{Tools → Geomtry}/VoxelMeshBVHBuilder.d.ts +0 -0
  166. /package/Mesher/{Tools → Geomtry}/VoxelMeshBVHBuilder.js +0 -0
  167. /package/Mesher/Geomtry/{Buffers.d.ts → VoxelMeshBuffers.d.ts} +0 -0
  168. /package/Mesher/Geomtry/{Buffers.js → VoxelMeshBuffers.js} +0 -0
  169. /package/Mesher/{Tools → Geomtry}/VoxelMeshVertexStructCursor.d.ts +0 -0
  170. /package/Mesher/{Tools → Geomtry}/VoxelMeshVertexStructCursor.js +0 -0
  171. /package/Mesher/{VoxelShaderData.d.ts → Geomtry/VoxelShaderData.d.ts} +0 -0
  172. /package/Mesher/{VoxelShaderData.js → Geomtry/VoxelShaderData.js} +0 -0
  173. /package/{World/Storage/WorldStorage.interface.js → Voxels/Cursor/DataCursor.interface.js} +0 -0
  174. /package/World/{Storage → Types}/WorldStorage.interface.d.ts +0 -0
@@ -1,120 +0,0 @@
1
- export class TextureBuilder {
2
- static context = null;
3
- static _textureSize = 16;
4
- static finalImagWidth = 16;
5
- static finalImageHeight = 16;
6
- static _canvas = document.createElement("canvas");
7
- static defineTextureDimensions(textureSize) {
8
- this.finalImagWidth = textureSize < 256 ? 256 : textureSize;
9
- this.finalImageHeight = textureSize < 256 ? 256 : textureSize;
10
- this._textureSize = textureSize;
11
- }
12
- static setUpImageCreation() {
13
- this._canvas.width = this.finalImagWidth;
14
- this._canvas.height = this.finalImageHeight;
15
- const context = this._canvas.getContext("2d", { willReadFrequently: true });
16
- if (!context) {
17
- throw new Error("Context did not load for texture creation.");
18
- }
19
- document.body.append(this._canvas);
20
- /* this._canvas.setAttribute(
21
- "style",
22
- `
23
- image-rendering: pixelated;
24
- position: absolute;
25
- border: 1px solid red;
26
- z-index: 1000;
27
- top: 0;
28
- `
29
- );
30
-
31
- */
32
- this.context = context;
33
- }
34
- static async createMaterialTexture(name, images, width = -1, height = -1) {
35
- if (width == -1)
36
- width = this.finalImagWidth;
37
- if (height == -1)
38
- height = this.finalImageHeight;
39
- this._canvas.width = this.finalImagWidth;
40
- this._canvas.height = this.finalImageHeight;
41
- const resolvedImages = [];
42
- for (const [path, rawData] of images) {
43
- const data = await this.loadImage(rawData ? rawData : path, width, height);
44
- resolvedImages.push(data);
45
- }
46
- return resolvedImages;
47
- }
48
- static async getRawData(imageSrc) {
49
- return new Promise((resolve, reject) => {
50
- const image = new Image();
51
- image.crossOrigin = "Anonymous";
52
- image.src = imageSrc;
53
- image.onload = () => {
54
- if (!this.context) {
55
- return reject(new Error("Context is not set for texture creation."));
56
- }
57
- this._canvas.width = image.width;
58
- this._canvas.height = image.height;
59
- this.context.clearRect(0, 0, image.width, image.height);
60
- this.context.drawImage(image, 0, 0, image.width, image.height);
61
- const imgData = this.context.getImageData(0, 0, image.width, image.height);
62
- resolve(imgData.data);
63
- this._canvas.width = this.finalImagWidth;
64
- this._canvas.height = this.finalImageHeight;
65
- };
66
- image.onerror = (err) => reject(err);
67
- });
68
- }
69
- static async getBase64(imageSrc) {
70
- return new Promise((resolve, reject) => {
71
- const image = new Image();
72
- image.crossOrigin = "Anonymous";
73
- image.src = imageSrc;
74
- image.onload = () => {
75
- if (!this.context) {
76
- return reject(new Error("Context is not set for texture creation."));
77
- }
78
- this._canvas.width = image.width;
79
- this._canvas.height = image.height;
80
- this.context.clearRect(0, 0, image.width, image.height);
81
- this.context.drawImage(image, 0, 0, image.width, image.height);
82
- resolve(this._canvas.toDataURL("image/png"));
83
- this._canvas.width = this.finalImagWidth;
84
- this._canvas.height = this.finalImageHeight;
85
- };
86
- image.onerror = (err) => reject(err);
87
- });
88
- }
89
- static async loadImage(imgSrcData, width = 0, height = 0) {
90
- if (!width)
91
- width = this.finalImagWidth;
92
- if (!height)
93
- height = this.finalImageHeight;
94
- const ctx = TextureBuilder.context;
95
- if (!ctx) {
96
- throw new Error("Context is not set for texture creation.");
97
- }
98
- const prom = new Promise((resolve) => {
99
- const image = typeof imgSrcData == "string" ? new Image() : imgSrcData;
100
- if (typeof imgSrcData == "string")
101
- image.src = imgSrcData;
102
- image.onload = () => {
103
- ctx.clearRect(0, 0, this._canvas.width, this._canvas.height);
104
- ctx.imageSmoothingEnabled = false;
105
- ctx.save();
106
- ctx.translate(0, this._canvas.height);
107
- ctx.scale(1, -1);
108
- ctx.drawImage(image, 0, 0, this._canvas.width, this._canvas.height);
109
- ctx.restore();
110
- const dataUrl = this._canvas.toDataURL("image/png");
111
- const returnImage = new Image(this._canvas.width, this._canvas.height);
112
- returnImage.src = dataUrl;
113
- returnImage.onload = () => {
114
- resolve(returnImage);
115
- };
116
- };
117
- });
118
- return prom;
119
- }
120
- }
@@ -1,9 +0,0 @@
1
- import type { TextureTypeUVMap, TextureId } from "./Texture.types";
2
- export declare class TextureRegister {
3
- static textureDataHasBeenSet: boolean;
4
- static data: TextureTypeUVMap;
5
- static getTextureUV(data: TextureId): number;
6
- static setTextureIndex(data: TextureTypeUVMap): void;
7
- static releaseTextureData(): void;
8
- static isReady(): boolean;
9
- }
@@ -1,28 +0,0 @@
1
- export class TextureRegister {
2
- static textureDataHasBeenSet = false;
3
- static data;
4
- static getTextureUV(data) {
5
- const [textureType, textureId, varation] = data;
6
- let id = textureId;
7
- if (varation) {
8
- id = `${textureId}:${varation}`;
9
- }
10
- let uv = -1;
11
- uv = this.data[textureType][id];
12
- if (uv == -1) {
13
- throw new Error(`Texture with id: ${id} does not exists.`);
14
- }
15
- return uv;
16
- }
17
- static setTextureIndex(data) {
18
- this.textureDataHasBeenSet = true;
19
- this.data = data;
20
- }
21
- static releaseTextureData() {
22
- this.data = null;
23
- delete this["data"];
24
- }
25
- static isReady() {
26
- return this.textureDataHasBeenSet;
27
- }
28
- }
@@ -1,5 +0,0 @@
1
- import { VoxelCursorInterface } from "../Voxels/Cursor/VoxelCursor.interface";
2
- export declare abstract class DataCursorInterface {
3
- abstract getVoxel(x: number, y: number, z: number): VoxelCursorInterface | null;
4
- abstract inBounds(x: number, y: number, z: number): boolean;
5
- }
@@ -1,2 +0,0 @@
1
- export class DataCursorInterface {
2
- }
@@ -1,16 +0,0 @@
1
- export function getBitValue(data, bitIndex, bitSize) {
2
- const mask = 2 ** bitSize - 1;
3
- return ((mask << bitIndex) & data) >>> bitIndex;
4
- }
5
- export function setBitValue(data, bitIndex, value, bitSize) {
6
- const mask = 2 ** bitSize - 1;
7
- return (data & ~(mask << bitIndex)) | ((value & mask) << bitIndex);
8
- }
9
- export function getBitArrayIndex(data, arrayIndex) {
10
- const arrayByteIndex = (arrayIndex / 8) >> 0;
11
- return getBitValue(data[arrayByteIndex], arrayIndex - arrayByteIndex * 8, 1);
12
- }
13
- export function setBitArrayIndex(data, arrayIndex, value) {
14
- const arrayByteIndex = (arrayIndex / 8) >> 0;
15
- data[arrayByteIndex] = setBitValue(data[arrayByteIndex], arrayIndex - arrayByteIndex * 8, value, 1);
16
- }
@@ -1,8 +0,0 @@
1
- export declare enum WorldDataStructProperties {
2
- header = "dve_header",
3
- dataType = "dve_data_type",
4
- dimensionId = "dve_dimension_id",
5
- positionX = "dve_p_x",
6
- positionY = "dve_p_y",
7
- positionZ = "dve_p_z"
8
- }
@@ -1,9 +0,0 @@
1
- export var WorldDataStructProperties;
2
- (function (WorldDataStructProperties) {
3
- WorldDataStructProperties["header"] = "dve_header";
4
- WorldDataStructProperties["dataType"] = "dve_data_type";
5
- WorldDataStructProperties["dimensionId"] = "dve_dimension_id";
6
- WorldDataStructProperties["positionX"] = "dve_p_x";
7
- WorldDataStructProperties["positionY"] = "dve_p_y";
8
- WorldDataStructProperties["positionZ"] = "dve_p_z";
9
- })(WorldDataStructProperties || (WorldDataStructProperties = {}));