@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.
- package/Contexts/Render/DivineVoxelEngineRender.d.ts +1 -1
- package/Contexts/World/DivineVoxelEngineWorld.d.ts +1 -1
- package/Init/StartConstructor.js +6 -4
- package/Init/StartWorld.d.ts +1 -1
- package/Mesher/Functions/CompactVoxelMesh.d.ts +2 -2
- package/Mesher/Functions/CompactVoxelMesh.js +1 -1
- package/Mesher/Functions/MeshSection.js +20 -8
- package/Mesher/Functions/MeshTexture.d.ts +1 -1
- package/Mesher/Functions/MeshTexture.js +3 -4
- 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 +2 -2
- package/Mesher/Geomtry/VoxelMesh.d.ts +1 -1
- package/Mesher/Geomtry/VoxelMesh.js +2 -2
- package/Mesher/Geomtry/index.d.ts +0 -1
- package/Mesher/Geomtry/index.js +0 -1
- package/Mesher/InitMesher.js +1 -1
- package/Mesher/InitTask.js +4 -22
- package/Mesher/Models/Common/Calc/FaceDataCalc.d.ts +2 -2
- package/Mesher/Models/Common/Calc/FaceDataCalc.js +37 -30
- 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.js +11 -17
- package/Mesher/Models/Nodes/GeometryNode.d.ts +2 -2
- package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.d.ts +1 -0
- package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.js +24 -12
- 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 +3 -3
- package/Mesher/Models/VoxelGeometryBuilderCacheSpace.d.ts +1 -3
- package/Mesher/Models/VoxelGeometryBuilderCacheSpace.js +0 -23
- package/Mesher/{Tools/VoxelMesherDataTool.d.ts → Models/VoxelModelBuilder.d.ts} +4 -5
- package/Mesher/{Tools/VoxelMesherDataTool.js → Models/VoxelModelBuilder.js} +11 -7
- 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/Rules/Functions/BuildFinalInputs.js +9 -7
- package/Models/Rules/Functions/BuildGeomtryInputs.js +8 -5
- package/Models/Rules/Functions/BuildRules.js +2 -2
- 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 +13 -1
- package/Tasks/IWG/Internal/Classes/IWGTaskBase.js +2 -2
- package/Tasks/IWG/Internal/Functions/runBuildUpdate.js +21 -2
- package/Tasks/IWG/Internal/IWGTasks.d.ts +0 -4
- package/Tasks/IWG/Internal/IWGTasks.js +0 -10
- package/Tasks/IWG/Internal/IWGTools.d.ts +1 -1
- package/Tasks/IWG/Procedures/SaveAllSectors.js +2 -0
- package/Tasks/Update/UpdateTask.d.ts +3 -1
- package/Tasks/Update/UpdateTask.js +28 -2
- package/Tasks/Update/VoxelUpdate.js +6 -0
- package/Tasks/WorldGeneration/WorldGenBrush.js +1 -1
- package/Templates/Cursor/TemplateCursor.d.ts +2 -2
- package/Templates/Cursor/TemplateCursor.js +1 -2
- 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 -1
- package/Tools/Brush/Brush.js +39 -7
- 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/{BitArray.d.ts → BinaryFunctions.d.ts} +1 -2
- package/Util/Binary/BinaryFunctions.js +11 -0
- package/Voxels/Cursor/DataCursor.interface.d.ts +5 -0
- package/Voxels/Cursor/VoxelCursor.interface.d.ts +1 -1
- package/Voxels/Cursor/VoxelCursor.interface.js +8 -11
- package/Voxels/Data/VoxelPalettesRegister.d.ts +0 -5
- package/Voxels/Data/VoxelPalettesRegister.js +0 -9
- package/Voxels/Data/VoxelTagsRegister.js +7 -7
- package/Voxels/Functions/BuildStateData.js +9 -9
- package/Voxels/Functions/BuildTagAndPaletteData.js +2 -4
- package/Voxels/InitVoxelData.js +12 -13
- package/Voxels/State/Schema/StateSchema.d.ts +1 -1
- package/Voxels/Types/Voxel.types.d.ts +18 -0
- package/Voxels/Types/Voxel.types.js +6 -2
- package/World/Archive/Archive.types.d.ts +38 -34
- package/World/Archive/Functions/ArchiveArea.js +16 -24
- package/World/Archive/Functions/ArchiveSector.js +477 -192
- package/World/Archive/Functions/ImportSector.d.ts +3 -3
- package/World/Archive/Functions/ImportSector.js +202 -141
- 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 +2 -2
- package/World/Cursor/SectionCursor.js +2 -3
- package/World/Cursor/SectorCursor.d.ts +2 -2
- package/World/Cursor/SectorCursor.js +1 -2
- package/World/Cursor/WorldCursor.d.ts +2 -2
- package/World/Cursor/WorldCursor.js +1 -2
- package/World/Cursor/WorldVoxelCursor.js +1 -0
- package/World/InitTasks.d.ts +1 -1
- package/World/Lock/WorldLock.d.ts +1 -1
- package/World/Section/Section.d.ts +12 -16
- package/World/Section/Section.js +62 -20
- package/World/Section/SectionState.d.ts +10 -0
- package/World/Section/SectionState.js +11 -0
- package/World/Sector/Sector.d.ts +14 -6
- package/World/Sector/Sector.js +67 -17
- package/World/Sector/SectorHeightMap.js +2 -2
- package/World/Sector/SectorState.d.ts +14 -6
- package/World/Sector/SectorState.js +28 -15
- package/World/Types/WorldStorage.interface.js +1 -0
- package/World/WorldRegister.d.ts +4 -0
- package/World/WorldRegister.js +15 -3
- package/World/WorldSpaces.d.ts +4 -0
- package/World/WorldSpaces.js +19 -6
- package/package.json +1 -1
- package/Mesher/Functions/CompactMesh.d.ts +0 -2
- package/Mesher/Functions/CompactMesh.js +0 -42
- 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/DataCursor.interface.d.ts +0 -5
- package/Tools/DataCursor.interface.js +0 -2
- package/Util/Binary/BitArray.js +0 -16
- package/World/Structs/WorldDataStructProperties.d.ts +0 -8
- package/World/Structs/WorldDataStructProperties.js +0 -9
- /package/Mesher/{Tools → Geomtry}/VoxelMeshBVHBuilder.d.ts +0 -0
- /package/Mesher/{Tools → Geomtry}/VoxelMeshBVHBuilder.js +0 -0
- /package/Mesher/Geomtry/{Buffers.d.ts → VoxelMeshBuffers.d.ts} +0 -0
- /package/Mesher/Geomtry/{Buffers.js → VoxelMeshBuffers.js} +0 -0
- /package/Mesher/{Tools → Geomtry}/VoxelMeshVertexStructCursor.d.ts +0 -0
- /package/Mesher/{Tools → Geomtry}/VoxelMeshVertexStructCursor.js +0 -0
- /package/Mesher/{VoxelShaderData.d.ts → Geomtry/VoxelShaderData.d.ts} +0 -0
- /package/Mesher/{VoxelShaderData.js → Geomtry/VoxelShaderData.js} +0 -0
- /package/{World/Storage/WorldStorage.interface.js → Voxels/Cursor/DataCursor.interface.js} +0 -0
- /package/World/{Storage → Types}/WorldStorage.interface.d.ts +0 -0
package/Tasks/IWG/IWG.js
CHANGED
|
@@ -29,10 +29,11 @@ export class IWG {
|
|
|
29
29
|
IWGTools.taskTool = new TaskTool(data.threads);
|
|
30
30
|
if (data.worldStorage)
|
|
31
31
|
IWGTools.worldStorage = data.worldStorage;
|
|
32
|
-
console.warn("load the thing", IWGTools.worldStorage, data.worldStorage);
|
|
33
32
|
}
|
|
34
33
|
static createGenerator(data) {
|
|
35
|
-
|
|
34
|
+
if (!initalized)
|
|
35
|
+
throw new Error(`IWG must be initalized first before creating generator`);
|
|
36
|
+
return new Generator(IWGTools.taskTool, {
|
|
36
37
|
dimension: data.dimension ? data.dimension : "main",
|
|
37
38
|
position: data.position ? data.position : Vector3Like.Create(),
|
|
38
39
|
renderRadius: data.renderRadius ? data.renderRadius : 150,
|
|
@@ -53,6 +54,11 @@ export class IWG {
|
|
|
53
54
|
}
|
|
54
55
|
return false;
|
|
55
56
|
}
|
|
57
|
+
static tick() {
|
|
58
|
+
for (const gen of this._generators) {
|
|
59
|
+
gen.tick();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
56
62
|
static update() {
|
|
57
63
|
if (!initalized) {
|
|
58
64
|
throw new Error(`IWG must be initalized.`);
|
|
@@ -77,7 +83,7 @@ export class IWG {
|
|
|
77
83
|
}
|
|
78
84
|
}
|
|
79
85
|
runBuildUpdate(this._generators);
|
|
80
|
-
IWGTasks.buildTasks.runTask();
|
|
86
|
+
// IWGTasks.buildTasks.runTask();
|
|
81
87
|
runWorldUpdate(this._generators);
|
|
82
88
|
IWGTasks.worldLoadTasks.runTask();
|
|
83
89
|
IWGTasks.worldGenTasks.runTask();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { LocationData } from "../../../../Math";
|
|
2
|
+
import { TaskTool } from "../../../../Tools/Tasks/TasksTool";
|
|
3
|
+
export declare class BuildQueue {
|
|
4
|
+
tasks: TaskTool;
|
|
5
|
+
hash: Set<unknown>;
|
|
6
|
+
sections: LocationData[];
|
|
7
|
+
constructor(tasks: TaskTool);
|
|
8
|
+
add(data: LocationData): false | undefined;
|
|
9
|
+
sort(x: number, y: number, z: number): void;
|
|
10
|
+
run(limit?: number): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { WorldSpaces } from "../../../../World/WorldSpaces";
|
|
2
|
+
export class BuildQueue {
|
|
3
|
+
tasks;
|
|
4
|
+
hash = new Set();
|
|
5
|
+
sections = [];
|
|
6
|
+
constructor(tasks) {
|
|
7
|
+
this.tasks = tasks;
|
|
8
|
+
}
|
|
9
|
+
add(data) {
|
|
10
|
+
const key = WorldSpaces.hash.hashXYZ(data[1], data[2], data[3]);
|
|
11
|
+
if (this.hash.has(key))
|
|
12
|
+
return false;
|
|
13
|
+
this.hash.add(key);
|
|
14
|
+
this.sections.push(data);
|
|
15
|
+
}
|
|
16
|
+
sort(x, y, z) {
|
|
17
|
+
const sections = this.sections;
|
|
18
|
+
const sx = x, sy = y, sz = z;
|
|
19
|
+
let i = sections.length, j, temp, ax, ay, az, bx, by, bz, distA, distB;
|
|
20
|
+
while (i > 1) {
|
|
21
|
+
for (j = 1; j < i; j++) {
|
|
22
|
+
(ax = sections[j - 1][1]),
|
|
23
|
+
(ay = sections[j - 1][2]),
|
|
24
|
+
(az = sections[j - 1][3]);
|
|
25
|
+
(bx = sections[j][1]), (by = sections[j][2]), (bz = sections[j][3]);
|
|
26
|
+
distA = (ax - sx) ** 2 + (ay - sy) ** 2 + (az - sz) ** 2;
|
|
27
|
+
distB = (bx - sx) ** 2 + (by - sy) ** 2 + (bz - sz) ** 2;
|
|
28
|
+
if (distA > distB) {
|
|
29
|
+
temp = sections[j - 1];
|
|
30
|
+
sections[j - 1] = sections[j];
|
|
31
|
+
sections[j] = temp;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
i--;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
run(limit = 25) {
|
|
38
|
+
let count = 0;
|
|
39
|
+
while (this.sections.length) {
|
|
40
|
+
const vec = this.sections.shift();
|
|
41
|
+
const [dimension, x, y, z] = vec;
|
|
42
|
+
this.tasks.build.section.run([dimension, x, y, z]);
|
|
43
|
+
this.hash.delete(WorldSpaces.hash.hashXYZ(x, y, z));
|
|
44
|
+
count++;
|
|
45
|
+
if (count > limit)
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Vector3Like } from "@amodx/math";
|
|
2
2
|
import { Circle } from "@amodx/math/Shapes";
|
|
3
|
+
import { BuildQueue } from "./BuildQueue";
|
|
4
|
+
import { TaskTool } from "../../../../Tools/Tasks/TasksTool";
|
|
3
5
|
export interface GeneratorData {
|
|
4
6
|
dimension: string;
|
|
5
7
|
building?: boolean;
|
|
@@ -10,6 +12,7 @@ export interface GeneratorData {
|
|
|
10
12
|
maxRadius: number;
|
|
11
13
|
}
|
|
12
14
|
export declare class Generator {
|
|
15
|
+
taskTool: TaskTool;
|
|
13
16
|
position: Vector3Like;
|
|
14
17
|
_dimension: string;
|
|
15
18
|
_building: boolean;
|
|
@@ -22,6 +25,8 @@ export declare class Generator {
|
|
|
22
25
|
_genCircle: Circle;
|
|
23
26
|
_renderCircle: Circle;
|
|
24
27
|
_maxCircle: Circle;
|
|
25
|
-
|
|
28
|
+
buildQueue: BuildQueue;
|
|
29
|
+
constructor(taskTool: TaskTool, data: GeneratorData);
|
|
26
30
|
update(): void;
|
|
31
|
+
tick(): void;
|
|
27
32
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Vector3Like } from "@amodx/math";
|
|
2
2
|
import { Circle } from "@amodx/math/Shapes";
|
|
3
3
|
import { WorldSpaces } from "../../../../World/WorldSpaces";
|
|
4
|
+
import { BuildQueue } from "./BuildQueue";
|
|
4
5
|
export class Generator {
|
|
6
|
+
taskTool;
|
|
5
7
|
position;
|
|
6
8
|
_dimension = "main";
|
|
7
9
|
_building = true;
|
|
@@ -14,7 +16,10 @@ export class Generator {
|
|
|
14
16
|
_genCircle = new Circle({ x: 0, y: 0 }, 0);
|
|
15
17
|
_renderCircle = new Circle({ x: 0, y: 0 }, 0);
|
|
16
18
|
_maxCircle = new Circle({ x: 0, y: 0 }, 10);
|
|
17
|
-
|
|
19
|
+
buildQueue;
|
|
20
|
+
constructor(taskTool, data) {
|
|
21
|
+
this.taskTool = taskTool;
|
|
22
|
+
console.warn("make generator", taskTool);
|
|
18
23
|
this._dimension = data.dimension;
|
|
19
24
|
this.position = data.position;
|
|
20
25
|
this._building =
|
|
@@ -23,6 +28,7 @@ export class Generator {
|
|
|
23
28
|
this._renderCircle.radius = data.renderRadius;
|
|
24
29
|
this._genCircle.radius = data.generationRadius;
|
|
25
30
|
this._maxCircle.radius = data.maxRadius;
|
|
31
|
+
this.buildQueue = new BuildQueue(taskTool);
|
|
26
32
|
}
|
|
27
33
|
update() {
|
|
28
34
|
this._positonChanged = false;
|
|
@@ -38,4 +44,10 @@ export class Generator {
|
|
|
38
44
|
this._maxCircle.center.x = this._sectorPosition.x;
|
|
39
45
|
this._maxCircle.center.y = this._sectorPosition.z;
|
|
40
46
|
}
|
|
47
|
+
tick() {
|
|
48
|
+
if (this._building) {
|
|
49
|
+
this.buildQueue.sort(this.position.x, this.position.y, this.position.z);
|
|
50
|
+
this.buildQueue.run(25);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
41
53
|
}
|
|
@@ -47,12 +47,12 @@ export class IWGTaskBase {
|
|
|
47
47
|
const z = task.queue.shift();
|
|
48
48
|
task.waitingFor++;
|
|
49
49
|
if (this.data.propagationBlocking) {
|
|
50
|
-
dimension.inProgress.add(x,
|
|
50
|
+
dimension.inProgress.add(x, y, z);
|
|
51
51
|
}
|
|
52
52
|
this.data.run([dimension.id, x, y, z], () => {
|
|
53
53
|
task.vistedMap.remove(x, y, z);
|
|
54
54
|
if (this.data.propagationBlocking) {
|
|
55
|
-
dimension.inProgress.remove(x,
|
|
55
|
+
dimension.inProgress.remove(x, y, z);
|
|
56
56
|
}
|
|
57
57
|
task.waitingFor--;
|
|
58
58
|
}, dimension);
|
|
@@ -3,10 +3,25 @@ import { WorldSpaces } from "../../../../World/WorldSpaces";
|
|
|
3
3
|
import { SectorState } from "../Classes/SectorState";
|
|
4
4
|
import { WorldRegister } from "../../../../World/WorldRegister";
|
|
5
5
|
import { getSectorState } from "./getSectorState";
|
|
6
|
-
import { IWGTasks } from "../IWGTasks";
|
|
7
6
|
import { IWGDimensions } from "../IWGDimensions";
|
|
8
7
|
const stateCursor = new SectorState();
|
|
9
8
|
const sectorSquare = new Square();
|
|
9
|
+
function run(dimenion, sector, location, generator) {
|
|
10
|
+
let rendered = true;
|
|
11
|
+
if (!dimenion.rendered.has(location[1], location[2], location[3])) {
|
|
12
|
+
rendered = false;
|
|
13
|
+
dimenion.rendered.add(location[1], location[2], location[3]);
|
|
14
|
+
}
|
|
15
|
+
for (const section of sector.getRenerableSections()) {
|
|
16
|
+
if (rendered && (section.isInProgress() || !section.isDirty()))
|
|
17
|
+
continue;
|
|
18
|
+
section.setInProgress(true);
|
|
19
|
+
generator.buildQueue.add([
|
|
20
|
+
location[0],
|
|
21
|
+
...section.getPosition(),
|
|
22
|
+
]);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
10
25
|
export function runBuildUpdate(generators) {
|
|
11
26
|
for (const generator of generators) {
|
|
12
27
|
if (!generator._building)
|
|
@@ -39,9 +54,13 @@ export function runBuildUpdate(generators) {
|
|
|
39
54
|
if (state.nWorldGenAllDone &&
|
|
40
55
|
state.nSunAllDone &&
|
|
41
56
|
state.nPropagtionAllDone) {
|
|
57
|
+
if (sector.anySectionDirty()) {
|
|
58
|
+
run(segment, sector, [generator._dimension, cx, cy, cz], generator);
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
42
61
|
if (segment.rendered.has(cx, cy, cz))
|
|
43
62
|
continue;
|
|
44
|
-
|
|
63
|
+
run(segment, sector, [generator._dimension, cx, cy, cz], generator);
|
|
45
64
|
}
|
|
46
65
|
}
|
|
47
66
|
}
|
|
@@ -126,14 +126,4 @@ export class IWGTasks {
|
|
|
126
126
|
onDone();
|
|
127
127
|
},
|
|
128
128
|
});
|
|
129
|
-
/**# Build Task
|
|
130
|
-
* ---
|
|
131
|
-
*/
|
|
132
|
-
static buildTasks = TaskRegister.addTasks({
|
|
133
|
-
id: "build_tasks",
|
|
134
|
-
async run(location, onDone, dimenion) {
|
|
135
|
-
dimenion.rendered.add(location[1], location[2], location[3]);
|
|
136
|
-
IWGTools.taskTool.build.sector.run(location, null, onDone);
|
|
137
|
-
},
|
|
138
|
-
});
|
|
139
129
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Thread } from "@amodx/threads";
|
|
2
2
|
import { TaskTool } from "../../../Tools/Tasks/TasksTool";
|
|
3
|
-
import { WorldStorageInterface } from "../../../World/
|
|
3
|
+
import { WorldStorageInterface } from "../../../World/Types/WorldStorage.interface";
|
|
4
4
|
export declare class IWGTools {
|
|
5
5
|
static taskTool: TaskTool;
|
|
6
6
|
static worldStorage: WorldStorageInterface | null;
|
|
@@ -13,6 +13,8 @@ export default async function SaveAllSectors() {
|
|
|
13
13
|
for (const [dimensionId] of IWGDimensions._dimensions) {
|
|
14
14
|
const dimension = WorldRegister.dimensions.get(dimensionId);
|
|
15
15
|
for (const [key, sector] of dimension.sectors) {
|
|
16
|
+
if (sector.isStored())
|
|
17
|
+
continue;
|
|
16
18
|
proms.push(worldStorage.saveSector([dimensionId, ...sector.position]));
|
|
17
19
|
}
|
|
18
20
|
}
|
|
@@ -15,10 +15,12 @@ declare class UpdatedBounds {
|
|
|
15
15
|
_task: UpdateTask;
|
|
16
16
|
min: Vector3Like;
|
|
17
17
|
max: Vector3Like;
|
|
18
|
+
dimension: string;
|
|
18
19
|
constructor(_task: UpdateTask);
|
|
19
|
-
|
|
20
|
+
start(dimension?: string): void;
|
|
20
21
|
update(x: number, y: number, z: number): void;
|
|
21
22
|
getSections(): Vec3Array[];
|
|
23
|
+
markSectionsAsDirty(): void;
|
|
22
24
|
}
|
|
23
25
|
export declare class UpdateTask {
|
|
24
26
|
flow: FlowQueues;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { WorldCursor } from "../../World/Cursor/WorldCursor";
|
|
2
2
|
import { Vector3Like } from "@amodx/math";
|
|
3
3
|
import { WorldSpaces } from "../../World/WorldSpaces";
|
|
4
|
+
import { WorldRegister } from "../../World/WorldRegister";
|
|
4
5
|
export class TaskMap {
|
|
5
6
|
_map = [];
|
|
6
7
|
get size() {
|
|
@@ -34,10 +35,12 @@ class UpdatedBounds {
|
|
|
34
35
|
_task;
|
|
35
36
|
min = Vector3Like.Clone(InfinityVec3);
|
|
36
37
|
max = Vector3Like.Clone(NegativeInfinityVec3);
|
|
38
|
+
dimension = "main";
|
|
37
39
|
constructor(_task) {
|
|
38
40
|
this._task = _task;
|
|
39
41
|
}
|
|
40
|
-
|
|
42
|
+
start(dimension) {
|
|
43
|
+
this.dimension = dimension || "main";
|
|
41
44
|
Vector3Like.Copy(this.min, InfinityVec3);
|
|
42
45
|
Vector3Like.Copy(this.max, NegativeInfinityVec3);
|
|
43
46
|
}
|
|
@@ -76,6 +79,29 @@ class UpdatedBounds {
|
|
|
76
79
|
}
|
|
77
80
|
return sectionPositions;
|
|
78
81
|
}
|
|
82
|
+
markSectionsAsDirty() {
|
|
83
|
+
const minSectionPos = WorldSpaces.section.getPosition(this.min.x - 1, this.min.y - 1, this.min.z - 1, tempPosition);
|
|
84
|
+
const minX = minSectionPos.x;
|
|
85
|
+
const minY = minSectionPos.y;
|
|
86
|
+
const minZ = minSectionPos.z;
|
|
87
|
+
const maxSectionPos = WorldSpaces.section.getPosition(this.max.x + 1, this.max.y + 1, this.max.z + 1, tempPosition);
|
|
88
|
+
const maxX = maxSectionPos.x;
|
|
89
|
+
const maxY = maxSectionPos.y;
|
|
90
|
+
const maxZ = maxSectionPos.z;
|
|
91
|
+
for (let x = minX; x <= maxX; x += WorldSpaces.section.bounds.x) {
|
|
92
|
+
for (let z = minZ; z <= maxZ; z += WorldSpaces.section.bounds.z) {
|
|
93
|
+
for (let y = minY; y <= maxY; y += WorldSpaces.section.bounds.y) {
|
|
94
|
+
if (!WorldSpaces.world.inBounds(x, y, z))
|
|
95
|
+
continue;
|
|
96
|
+
const sector = WorldRegister.sectors.get(this.dimension, x, y, z);
|
|
97
|
+
if (!sector)
|
|
98
|
+
continue;
|
|
99
|
+
const section = sector.getSection(x, y, z);
|
|
100
|
+
section.setDirty(true);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
79
105
|
}
|
|
80
106
|
export class UpdateTask {
|
|
81
107
|
flow = new FlowQueues();
|
|
@@ -96,13 +122,13 @@ export class UpdateTask {
|
|
|
96
122
|
this.flow.update.map.start(origin[1], origin[2], origin[3]);
|
|
97
123
|
this.flow.remove.map.start(origin[1], origin[2], origin[3]);
|
|
98
124
|
this.flow.remove.noRemoveMap.start(origin[1], origin[2], origin[3]);
|
|
125
|
+
this.bounds.start(origin[0]);
|
|
99
126
|
this.clear();
|
|
100
127
|
}
|
|
101
128
|
clear() {
|
|
102
129
|
this.rgb.clear();
|
|
103
130
|
this.sun.clear();
|
|
104
131
|
this.flow.clear();
|
|
105
|
-
this.bounds.reset();
|
|
106
132
|
}
|
|
107
133
|
}
|
|
108
134
|
class FlowQueues {
|
|
@@ -68,6 +68,8 @@ export async function EreaseAndUpdate(location) {
|
|
|
68
68
|
SunUpdate(tasks);
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
+
tasks.bounds.update(x, y, z);
|
|
72
|
+
tasks.bounds.update(x + 1, y + 1, z + 1);
|
|
71
73
|
for (let i = 0; i < $3dCardinalNeighbors.length; i++) {
|
|
72
74
|
tasks.sDataCursor
|
|
73
75
|
.getVoxel($3dCardinalNeighbors[i][0] + x, $3dCardinalNeighbors[i][1] + y, $3dCardinalNeighbors[i][2] + z)
|
|
@@ -136,6 +138,8 @@ export async function PaintAndUpdate(data) {
|
|
|
136
138
|
FlowUpdate(tasks);
|
|
137
139
|
}
|
|
138
140
|
}
|
|
141
|
+
tasks.bounds.update(x, y, z);
|
|
142
|
+
tasks.bounds.update(x + 1, y + 1, z + 1);
|
|
139
143
|
for (let i = 0; i < $3dCardinalNeighbors.length; i++) {
|
|
140
144
|
tasks.sDataCursor
|
|
141
145
|
.getVoxel($3dCardinalNeighbors[i][0] + x, $3dCardinalNeighbors[i][1] + y, $3dCardinalNeighbors[i][2] + z)
|
|
@@ -167,5 +171,7 @@ export async function VoxelUpdate(data) {
|
|
|
167
171
|
FlowUpdate(tasks);
|
|
168
172
|
}
|
|
169
173
|
}
|
|
174
|
+
tasks.bounds.update(x, y, z);
|
|
175
|
+
tasks.bounds.update(x + 1, y + 1, z + 1);
|
|
170
176
|
return tasks;
|
|
171
177
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TemplateVoxelCursor } from "./TemplateVoxelCursor";
|
|
2
|
-
import { DataCursorInterface } from "../../
|
|
2
|
+
import { DataCursorInterface } from "../../Voxels/Cursor/DataCursor.interface";
|
|
3
3
|
import { FullVoxelTemplate } from "Templates/FullVoxelTemplate";
|
|
4
|
-
export declare class TemplateCursor
|
|
4
|
+
export declare class TemplateCursor implements DataCursorInterface {
|
|
5
5
|
_voxelIndex: number;
|
|
6
6
|
_template: FullVoxelTemplate | null;
|
|
7
7
|
private voxel;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { TemplateVoxelCursor } from "./TemplateVoxelCursor";
|
|
2
|
-
|
|
3
|
-
export class TemplateCursor extends DataCursorInterface {
|
|
2
|
+
export class TemplateCursor {
|
|
4
3
|
_voxelIndex = 0;
|
|
5
4
|
_template = null;
|
|
6
5
|
voxel = new TemplateVoxelCursor(this);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Vec2Array } from "@amodx/math";
|
|
2
|
+
import { TextureId } from "../../Textures/Texture.types";
|
|
3
|
+
import { CompiledTextureAnimation } from "./CompiledTextureAnimation";
|
|
4
|
+
import { TextureAnimationTexture } from "./TextureAnimationTexture";
|
|
5
|
+
export declare class CompiledTexture {
|
|
6
|
+
id: string;
|
|
7
|
+
static GetAtlasIndex: (x: number, y: number, boundsX: number) => number;
|
|
8
|
+
static GetAtlasPosition: (index: number, boundsX: number, position?: Vec2Array) => Vec2Array;
|
|
9
|
+
images: HTMLImageElement[];
|
|
10
|
+
atlasSizeMap: Record<string, [width: number, height: number]>;
|
|
11
|
+
textureMap: Record<string, number>;
|
|
12
|
+
animations: CompiledTextureAnimation[];
|
|
13
|
+
shaderTexture: any;
|
|
14
|
+
animatedTexture: TextureAnimationTexture;
|
|
15
|
+
constructor(id: string);
|
|
16
|
+
getTextureIndex(id: TextureId): number;
|
|
17
|
+
getTexturePath(id: TextureId): string;
|
|
18
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { TextureAnimationTexture } from "./TextureAnimationTexture";
|
|
2
|
+
export class CompiledTexture {
|
|
3
|
+
id;
|
|
4
|
+
static GetAtlasIndex = (x, y, boundsX) => x + y * boundsX;
|
|
5
|
+
static GetAtlasPosition = (index, boundsX, position = [0, 0]) => {
|
|
6
|
+
position[1] = Math.floor(index / boundsX);
|
|
7
|
+
position[0] = Math.floor(index % boundsX);
|
|
8
|
+
return position;
|
|
9
|
+
};
|
|
10
|
+
images = [];
|
|
11
|
+
atlasSizeMap = {};
|
|
12
|
+
textureMap = {};
|
|
13
|
+
animations = [];
|
|
14
|
+
shaderTexture;
|
|
15
|
+
animatedTexture;
|
|
16
|
+
constructor(id) {
|
|
17
|
+
this.id = id;
|
|
18
|
+
this.animatedTexture = new TextureAnimationTexture(this);
|
|
19
|
+
}
|
|
20
|
+
getTextureIndex(id) {
|
|
21
|
+
let finalId = "";
|
|
22
|
+
let frameIndex = 0;
|
|
23
|
+
if (!Array.isArray(id)) {
|
|
24
|
+
finalId = id;
|
|
25
|
+
}
|
|
26
|
+
if (Array.isArray(id)) {
|
|
27
|
+
finalId = id[0];
|
|
28
|
+
if (typeof id[1] == "number")
|
|
29
|
+
frameIndex = id[1];
|
|
30
|
+
if (Array.isArray(id[1]))
|
|
31
|
+
frameIndex = CompiledTexture.GetAtlasIndex(id[1][0], id[1][1], this.atlasSizeMap[finalId][0]);
|
|
32
|
+
if (typeof id[1] == "string") {
|
|
33
|
+
finalId = `${id[0]}:${id[1]}`;
|
|
34
|
+
if (typeof id[2] == "number")
|
|
35
|
+
frameIndex = id[2];
|
|
36
|
+
if (Array.isArray(id[2]))
|
|
37
|
+
frameIndex = CompiledTexture.GetAtlasIndex(id[2][0], id[2][1], this.atlasSizeMap[finalId][0]);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const index = this.textureMap[finalId];
|
|
41
|
+
if (index === undefined) {
|
|
42
|
+
console.warn(`Texture with id [passed in: ${id.toString()}] [final: ${finalId}] does not exist on compiled texture [${this.id}]`);
|
|
43
|
+
return 0;
|
|
44
|
+
}
|
|
45
|
+
return index + frameIndex;
|
|
46
|
+
}
|
|
47
|
+
getTexturePath(id) {
|
|
48
|
+
return this.images[this.getTextureIndex(id)].src;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare class CompiledTextureAnimation {
|
|
2
|
+
textureIndex: number;
|
|
3
|
+
_frames: number[];
|
|
4
|
+
_times: number[];
|
|
5
|
+
_currentTime: number;
|
|
6
|
+
_frameIndex: number;
|
|
7
|
+
_current: number;
|
|
8
|
+
_animatedTextureIndex: number;
|
|
9
|
+
constructor(textureIndex: number);
|
|
10
|
+
tick(delta: number): boolean;
|
|
11
|
+
getIndex(): number;
|
|
12
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export class CompiledTextureAnimation {
|
|
2
|
+
textureIndex;
|
|
3
|
+
_frames = [];
|
|
4
|
+
_times = [];
|
|
5
|
+
_currentTime = 0;
|
|
6
|
+
_frameIndex = 0;
|
|
7
|
+
_current = Infinity;
|
|
8
|
+
_animatedTextureIndex = -1;
|
|
9
|
+
constructor(textureIndex) {
|
|
10
|
+
this.textureIndex = textureIndex;
|
|
11
|
+
}
|
|
12
|
+
tick(delta) {
|
|
13
|
+
if (this._current == Infinity)
|
|
14
|
+
this._current = this._times[0];
|
|
15
|
+
this._current -= delta;
|
|
16
|
+
if (this._current <= 0) {
|
|
17
|
+
this._frameIndex++;
|
|
18
|
+
this._frameIndex %= this._frames.length;
|
|
19
|
+
this._current = this._times[this._frameIndex];
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
getIndex() {
|
|
25
|
+
return this._frames[this._frameIndex] + this.textureIndex;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CompiledTexture } from "./CompiledTexture";
|
|
2
|
+
export declare class TextureAnimationTexture {
|
|
3
|
+
_texture: CompiledTexture;
|
|
4
|
+
_buffer: Uint16Array;
|
|
5
|
+
_size: number;
|
|
6
|
+
shaderTexture: any;
|
|
7
|
+
constructor(_texture: CompiledTexture);
|
|
8
|
+
build(): Uint16Array;
|
|
9
|
+
tick(delta: number): boolean;
|
|
10
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { CompiledTexture } from "./CompiledTexture";
|
|
2
|
+
export class TextureAnimationTexture {
|
|
3
|
+
_texture;
|
|
4
|
+
_buffer;
|
|
5
|
+
_size = 0;
|
|
6
|
+
shaderTexture;
|
|
7
|
+
constructor(_texture) {
|
|
8
|
+
this._texture = _texture;
|
|
9
|
+
}
|
|
10
|
+
build() {
|
|
11
|
+
const totalTexture = this._texture.images.length;
|
|
12
|
+
const size = Math.pow(2, Math.ceil(Math.log2(Math.ceil(Math.sqrt(totalTexture)))));
|
|
13
|
+
this._size = size;
|
|
14
|
+
this._buffer = new Uint16Array(size * size);
|
|
15
|
+
for (let i = 0; i < this._texture.animations.length; i++) {
|
|
16
|
+
const anim = this._texture.animations[i];
|
|
17
|
+
anim._animatedTextureIndex = CompiledTexture.GetAtlasIndex(...CompiledTexture.GetAtlasPosition(anim.textureIndex, this._size), this._size);
|
|
18
|
+
}
|
|
19
|
+
return this._buffer;
|
|
20
|
+
}
|
|
21
|
+
tick(delta) {
|
|
22
|
+
let update = false;
|
|
23
|
+
for (let i = 0; i < this._texture.animations.length; i++) {
|
|
24
|
+
const anim = this._texture.animations[i];
|
|
25
|
+
if (anim.tick(delta)) {
|
|
26
|
+
update = true;
|
|
27
|
+
this._buffer[anim._animatedTextureIndex] = anim.getIndex();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return update;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CompiledTexture } from "../Classes/CompiledTexture";
|
|
2
|
+
import { TextureData } from "../../Textures/Texture.types";
|
|
3
|
+
export type BuildTextureDataProps = {
|
|
4
|
+
type: string;
|
|
5
|
+
baseURL?: string;
|
|
6
|
+
createCache?: boolean;
|
|
7
|
+
textures: TextureData[];
|
|
8
|
+
finalSize?: [width: number, height: number];
|
|
9
|
+
};
|
|
10
|
+
export declare function BuildTextureData({ type, baseURL: currentBaseURL, textures, finalSize: currentFinalSize, createCache, }: BuildTextureDataProps): Promise<CompiledTexture>;
|