@divinevoxel/vlox 0.0.5 → 0.0.6
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/Remote/InitWorldDataSync.js +2 -4
- package/Contexts/Render/DVERenderThreads.d.ts +1 -1
- package/Contexts/Render/DVERenderThreads.js +2 -2
- package/Contexts/Render/DivineVoxelEngineRender.js +1 -1
- package/Init/StartRenderer.js +5 -5
- package/Math/Indexing.js +6 -6
- package/Mesher/Functions/CompactVoxelMesh.js +40 -7
- package/Mesher/Functions/MeshSection.js +12 -8
- package/Mesher/Functions/MeshTexture.d.ts +1 -1
- package/Mesher/Functions/MeshVoxel.js +2 -1
- package/Mesher/Geomtry/Buffers.d.ts +19 -0
- package/Mesher/Geomtry/Buffers.js +81 -0
- package/Mesher/Geomtry/Tools/MesherDataTools.d.ts +3 -3
- package/Mesher/Geomtry/Tools/MesherDataTools.js +2 -2
- package/Mesher/Geomtry/VoxelGeometryBuilder.js +3 -3
- package/Mesher/Geomtry/VoxelMesh.d.ts +13 -0
- package/Mesher/Geomtry/VoxelMesh.js +28 -0
- package/Mesher/InitTask.js +1 -2
- package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.js +7 -7
- package/Mesher/Models/Nodes/Ruled/QuadVoxelGeometryNode.js +7 -7
- package/Mesher/Models/VoxelConstructor.js +3 -3
- package/Mesher/Models/VoxelGeometryLookUp.d.ts +20 -11
- package/Mesher/Models/VoxelGeometryLookUp.js +73 -39
- package/Mesher/Tools/VoxelMeshBVHBuilder.js +20 -25
- package/Mesher/Tools/VoxelMeshVertexStructCursor.d.ts +3 -1
- package/Mesher/Tools/VoxelMesherDataTool.d.ts +2 -2
- package/Mesher/Tools/VoxelMesherDataTool.js +3 -3
- package/Renderer/Classes/DVESectionMeshes.d.ts +1 -0
- package/Renderer/Classes/SectionMesh.d.ts +1 -2
- package/Renderer/Classes/SectionMesh.js +0 -3
- package/Renderer/InitTasks.js +13 -1
- package/Renderer/MeshManager.js +4 -0
- package/Renderer/MeshRegister.d.ts +1 -6
- package/Renderer/index.d.ts +0 -1
- package/Renderer/index.js +0 -1
- package/Tasks/IWG/Internal/Functions/cullSectors.js +1 -2
- package/Tasks/IWG/Internal/Functions/getSectorState.js +1 -1
- package/Tasks/IWG/Internal/Functions/runBuildUpdate.js +1 -2
- package/Tasks/IWG/Internal/Functions/runWorldUpdate.js +1 -2
- package/Tasks/IWG/Internal/IWGTasks.js +7 -13
- package/Tasks/Propagation/Flow/WorldFlow.js +2 -4
- package/Tasks/Propagation/Illumanation/WorldRGB.js +1 -2
- package/Tasks/Propagation/Illumanation/WorldSun.js +1 -4
- package/Tasks/WorldGeneration/WorldGenRegister.js +5 -8
- package/Tasks/WorldGeneration/WorldGeneration.d.ts +0 -2
- package/Tasks/WorldGeneration/WorldGeneration.js +0 -2
- package/Tools/Brush/Brush.js +1 -2
- package/World/Archive/Functions/ArchiveSector.d.ts +1 -1
- package/World/Archive/Functions/ArchiveSector.js +2 -3
- package/World/Archive/InitTasks.js +2 -3
- package/World/Cursor/SectionCursor.js +1 -2
- package/World/Cursor/SectorCursor.js +1 -2
- package/World/Cursor/WorldCursor.js +1 -2
- package/World/InitTasks.js +5 -10
- package/World/Lock/WorldLock.js +4 -5
- package/World/Sector/SectorHeightMap.js +4 -6
- package/World/WorldRegister.d.ts +4 -6
- package/World/WorldRegister.js +24 -20
- package/World/WorldSpaces.d.ts +21 -0
- package/World/WorldSpaces.js +58 -7
- package/package.json +1 -1
- package/Mesher/Geomtry/Mesh.d.ts +0 -11
- package/Mesher/Geomtry/Mesh.js +0 -23
- package/Renderer/Classes/DVESectionMeshInterface.d.ts +0 -3
- package/Renderer/Classes/DVESectionMeshInterface.js +0 -1
- package/World/WorldBounds.d.ts +0 -20
- package/World/WorldBounds.js +0 -53
|
@@ -132,9 +132,8 @@ function GetArchivedSection(archiveSection, sectorPalettes) {
|
|
|
132
132
|
},
|
|
133
133
|
};
|
|
134
134
|
}
|
|
135
|
-
export default function
|
|
136
|
-
WorldRegister.
|
|
137
|
-
const sector = WorldRegister.sectors.get(archiveData.location[1], archiveData.location[2], archiveData.location[3]);
|
|
135
|
+
export default function ArchiveSector(archiveData) {
|
|
136
|
+
const sector = WorldRegister.sectors.get(archiveData.location[0], archiveData.location[1], archiveData.location[2], archiveData.location[3]);
|
|
138
137
|
if (!sector)
|
|
139
138
|
throw new Error(`Column at location ${location} does not exist when trying to arhicve it.`);
|
|
140
139
|
if (!sectorStructInstance)
|
|
@@ -2,10 +2,9 @@ import { Threads } from "@amodx/threads";
|
|
|
2
2
|
import ArchiveSector from "./Functions/ArchiveSector";
|
|
3
3
|
import { WorldRegister } from "../WorldRegister";
|
|
4
4
|
import ImportSector from "./Functions/ImportSector";
|
|
5
|
-
import { compressBinaryObject, expandBinaryObject } from "../../Util/BinaryObject";
|
|
5
|
+
import { compressBinaryObject, expandBinaryObject, } from "../../Util/BinaryObject";
|
|
6
6
|
function runArchiveSector(location) {
|
|
7
|
-
WorldRegister.
|
|
8
|
-
const sector = WorldRegister.sectors.get(location[1], location[2], location[3]);
|
|
7
|
+
const sector = WorldRegister.sectors.get(location[0], location[1], location[2], location[3]);
|
|
9
8
|
if (!sector)
|
|
10
9
|
throw new Error(`Sector at location ${location.toString()} does not exist`);
|
|
11
10
|
const archived = ArchiveSector({
|
|
@@ -36,8 +36,7 @@ export class SectionCursor extends DataCursorInterface {
|
|
|
36
36
|
this._sectionPosition.z = sectionPos[2];
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
39
|
-
WorldRegister.
|
|
40
|
-
const sector = WorldRegister.sectors.get(x || 0, y || 0, z || 0);
|
|
39
|
+
const sector = WorldRegister.sectors.get(sectionOrDimension, x || 0, y || 0, z || 0);
|
|
41
40
|
if (!sector)
|
|
42
41
|
return false;
|
|
43
42
|
this._section = sector.getSection(y || 0);
|
|
@@ -29,8 +29,7 @@ export class SectorCursor extends DataCursorInterface {
|
|
|
29
29
|
return true;
|
|
30
30
|
}
|
|
31
31
|
setSector(dimension, x, y, z) {
|
|
32
|
-
WorldRegister.
|
|
33
|
-
const sector = WorldRegister.sectors.get(x, y, z);
|
|
32
|
+
const sector = WorldRegister.sectors.get(dimension, x, y, z);
|
|
34
33
|
if (!sector)
|
|
35
34
|
return false;
|
|
36
35
|
this._current = sector;
|
|
@@ -2,7 +2,6 @@ import { Vector3Like } from "@amodx/math";
|
|
|
2
2
|
import { SectorCursor } from "./SectorCursor";
|
|
3
3
|
import { WorldSpaces } from "../WorldSpaces";
|
|
4
4
|
import { DataCursorInterface } from "../../Data/Cursor/DataCursor.interface";
|
|
5
|
-
import { WorldBounds } from "../WorldBounds";
|
|
6
5
|
let cursorCache = [];
|
|
7
6
|
const tempPosition = Vector3Like.Create();
|
|
8
7
|
export class WorldCursor extends DataCursorInterface {
|
|
@@ -23,7 +22,7 @@ export class WorldCursor extends DataCursorInterface {
|
|
|
23
22
|
this.origin.z = sectorPos.z / WorldSpaces.sector.bounds.z;
|
|
24
23
|
}
|
|
25
24
|
inBounds(x, y, z) {
|
|
26
|
-
return
|
|
25
|
+
return WorldSpaces.world.inBounds(x, y, z);
|
|
27
26
|
}
|
|
28
27
|
getSector(x, y, z) {
|
|
29
28
|
const sectorPos = WorldSpaces.sector.getPosition(x, y, z, tempPosition);
|
package/World/InitTasks.js
CHANGED
|
@@ -29,8 +29,7 @@ export default function ({ threads, worldStorage, }) {
|
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
Threads.registerTask("add-sector", async (location) => {
|
|
32
|
-
WorldRegister.
|
|
33
|
-
const sector = WorldRegister.sectors.get(location[1], location[2], location[3]);
|
|
32
|
+
const sector = WorldRegister.sectors.get(location[0], location[1], location[2], location[3]);
|
|
34
33
|
if (sector) {
|
|
35
34
|
for (const thread of threads) {
|
|
36
35
|
thread.runTask(WorldDataSyncIds.SyncSector, [location, sector]);
|
|
@@ -38,8 +37,7 @@ export default function ({ threads, worldStorage, }) {
|
|
|
38
37
|
return;
|
|
39
38
|
}
|
|
40
39
|
if (!sector && !worldStorage) {
|
|
41
|
-
WorldRegister.
|
|
42
|
-
WorldRegister.sectors.new(location[1], location[2], location[3]);
|
|
40
|
+
WorldRegister.sectors.new(location[0], location[1], location[2], location[3]);
|
|
43
41
|
}
|
|
44
42
|
if (worldStorage) {
|
|
45
43
|
const sectorPos = WorldSpaces.sector.getPosition(location[1], location[2], location[3]);
|
|
@@ -56,8 +54,7 @@ export default function ({ threads, worldStorage, }) {
|
|
|
56
54
|
const success = await worldStorage.loadSector(sectorLocation);
|
|
57
55
|
loadInMap.delete(sectorId);
|
|
58
56
|
if (!success) {
|
|
59
|
-
WorldRegister.
|
|
60
|
-
WorldRegister.sectors.new(sectorLocation[1], sectorLocation[2], sectorLocation[3]);
|
|
57
|
+
WorldRegister.sectors.new(sectorLocation[0], sectorLocation[1], sectorLocation[2], sectorLocation[3]);
|
|
61
58
|
}
|
|
62
59
|
return;
|
|
63
60
|
}
|
|
@@ -71,16 +68,14 @@ export default function ({ threads, worldStorage, }) {
|
|
|
71
68
|
Threads.registerTask("unload-sector", (location) => {
|
|
72
69
|
if (WorldLock.isLocked(location))
|
|
73
70
|
return [false];
|
|
74
|
-
WorldRegister.
|
|
75
|
-
WorldRegister.sectors.remove(location[1], location[2], location[3]);
|
|
71
|
+
WorldRegister.sectors.remove(location[0], location[1], location[2], location[3]);
|
|
76
72
|
for (const thread of threads) {
|
|
77
73
|
thread.runTask(WorldDataSyncIds.UnSyncSector, location);
|
|
78
74
|
}
|
|
79
75
|
return [false];
|
|
80
76
|
});
|
|
81
77
|
Threads.registerTask("load-sector", ([location, sector]) => {
|
|
82
|
-
WorldRegister.
|
|
83
|
-
WorldRegister.sectors.add(location[1], location[2], location[3], sector);
|
|
78
|
+
WorldRegister.sectors.add(location[0], location[1], location[2], location[3], sector);
|
|
84
79
|
for (const thread of threads) {
|
|
85
80
|
thread.runTask(WorldDataSyncIds.SyncSector, [location, sector]);
|
|
86
81
|
}
|
package/World/Lock/WorldLock.js
CHANGED
|
@@ -23,8 +23,7 @@ export class WorldLock {
|
|
|
23
23
|
sectorPos.z,
|
|
24
24
|
];
|
|
25
25
|
location[0] = dim;
|
|
26
|
-
WorldRegister.
|
|
27
|
-
if (WorldRegister.sectors.get(location[1], location[2], location[3]))
|
|
26
|
+
if (WorldRegister.sectors.get(location[0], location[1], location[2], location[3]))
|
|
28
27
|
continue;
|
|
29
28
|
allFound = false;
|
|
30
29
|
const key = location.toString();
|
|
@@ -33,7 +32,7 @@ export class WorldLock {
|
|
|
33
32
|
this._loadMap.set(key, true);
|
|
34
33
|
let success = false;
|
|
35
34
|
if (!this.worldStorage) {
|
|
36
|
-
if (WorldRegister.sectors.get(location[1], location[2], location[3])) {
|
|
35
|
+
if (WorldRegister.sectors.get(location[0], location[1], location[2], location[3])) {
|
|
37
36
|
success = true;
|
|
38
37
|
}
|
|
39
38
|
}
|
|
@@ -41,10 +40,10 @@ export class WorldLock {
|
|
|
41
40
|
success = await this.worldStorage.loadSector(location);
|
|
42
41
|
}
|
|
43
42
|
this._loadMap.delete(key);
|
|
44
|
-
if (WorldRegister.sectors.get(location[1], location[2], location[3]))
|
|
43
|
+
if (WorldRegister.sectors.get(location[0], location[1], location[2], location[3]))
|
|
45
44
|
return;
|
|
46
45
|
if (!success) {
|
|
47
|
-
WorldRegister.sectors.new(location[1], location[2], location[3]);
|
|
46
|
+
WorldRegister.sectors.new(location[0], location[1], location[2], location[3]);
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
49
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { $2dMooreNeighborhood } from "../../Math/CardinalNeighbors";
|
|
2
2
|
import { SectionHeightMap } from "../Section/SectionHeightMap";
|
|
3
|
-
import { WorldBounds } from "../WorldBounds";
|
|
4
3
|
import { WorldRegister } from "../WorldRegister";
|
|
5
4
|
import { WorldSpaces } from "../WorldSpaces";
|
|
6
5
|
export class SectorHeightMap {
|
|
@@ -21,13 +20,12 @@ export class SectorHeightMap {
|
|
|
21
20
|
return maxHeight;
|
|
22
21
|
}
|
|
23
22
|
static getAbsolute(location) {
|
|
24
|
-
WorldRegister.
|
|
25
|
-
const sector = WorldRegister.sectors.get(location[1], location[2], location[3]);
|
|
23
|
+
const sector = WorldRegister.sectors.get(location[0], location[1], location[2], location[3]);
|
|
26
24
|
if (!sector)
|
|
27
|
-
return
|
|
25
|
+
return WorldSpaces.world.bounds.MinY;
|
|
28
26
|
if (sector.sections.length == 0)
|
|
29
|
-
return
|
|
30
|
-
let maxHeight =
|
|
27
|
+
return WorldSpaces.world.bounds.MinY;
|
|
28
|
+
let maxHeight = WorldSpaces.world.bounds.MinY;
|
|
31
29
|
const positon = [location[1], location[2], location[3]];
|
|
32
30
|
let y = positon[1];
|
|
33
31
|
for (let i = 0; i < sector.sections.length; i++) {
|
package/World/WorldRegister.d.ts
CHANGED
|
@@ -18,18 +18,16 @@ declare class WorldRegisterDimensions {
|
|
|
18
18
|
}
|
|
19
19
|
declare class WorldRegisterSectors {
|
|
20
20
|
static setSecotrPool(enabled: boolean): void;
|
|
21
|
-
static add(x: number, y: number, z: number, sector: SectorData): Sector;
|
|
22
|
-
static new(x: number, y: number, z: number): boolean;
|
|
23
|
-
static get(x: number, y: number, z: number): false | Sector;
|
|
24
|
-
static remove(x: number, y: number, z: number): boolean;
|
|
21
|
+
static add(dimensionId: string, x: number, y: number, z: number, sector: SectorData): Sector;
|
|
22
|
+
static new(dimensionId: string, x: number, y: number, z: number): boolean;
|
|
23
|
+
static get(dimensionId: string, x: number, y: number, z: number): false | Sector;
|
|
24
|
+
static remove(dimensionId: string, x: number, y: number, z: number): boolean;
|
|
25
25
|
}
|
|
26
26
|
export declare class WorldRegister {
|
|
27
27
|
static _dimensions: Map<string, Dimension>;
|
|
28
28
|
static _hooks: typeof WorldDataHooks;
|
|
29
29
|
static dimensions: typeof WorldRegisterDimensions;
|
|
30
30
|
static sectors: typeof WorldRegisterSectors;
|
|
31
|
-
static _currentDimension: Dimension;
|
|
32
|
-
static setDimension(dimensionId: string): void;
|
|
33
31
|
static clearAll(): void;
|
|
34
32
|
}
|
|
35
33
|
export {};
|
package/World/WorldRegister.js
CHANGED
|
@@ -42,33 +42,45 @@ class WorldRegisterSectors {
|
|
|
42
42
|
SectorPool._enabled = enabled;
|
|
43
43
|
SectorPool._secotrs.length = 0;
|
|
44
44
|
}
|
|
45
|
-
static add(x, y, z, sector) {
|
|
45
|
+
static add(dimensionId, x, y, z, sector) {
|
|
46
|
+
let dimension = WorldRegister.dimensions.get(dimensionId);
|
|
47
|
+
if (!dimension)
|
|
48
|
+
dimension = WorldRegister.dimensions.add(dimensionId);
|
|
46
49
|
WorldSpaces.sector.getPositionVec3Array(x, y, z, sector.position);
|
|
47
50
|
const newSector = new Sector(sector);
|
|
48
|
-
|
|
51
|
+
dimension.sectors.set(WorldSpaces.hash.hashVec3Array(newSector.position), newSector);
|
|
49
52
|
return newSector;
|
|
50
53
|
}
|
|
51
|
-
static new(x, y, z) {
|
|
52
|
-
if (this.get(x, y, z))
|
|
54
|
+
static new(dimensionId, x, y, z) {
|
|
55
|
+
if (this.get(dimensionId, x, y, z))
|
|
53
56
|
return false;
|
|
54
|
-
|
|
55
|
-
|
|
57
|
+
let dimension = WorldRegister.dimensions.get(dimensionId);
|
|
58
|
+
if (!dimension)
|
|
59
|
+
dimension = WorldRegister.dimensions.add(dimensionId);
|
|
60
|
+
const sector = this.add(dimensionId, x, y, z, Sector.CreateNew());
|
|
61
|
+
WorldDataHooks.sectors.onNew([dimensionId, x, y, z], sector);
|
|
56
62
|
return true;
|
|
57
63
|
}
|
|
58
|
-
static get(x, y, z) {
|
|
59
|
-
|
|
64
|
+
static get(dimensionId, x, y, z) {
|
|
65
|
+
let dimension = WorldRegister.dimensions.get(dimensionId);
|
|
66
|
+
if (!dimension)
|
|
67
|
+
return false;
|
|
68
|
+
const sector = dimension.sectors.get(WorldSpaces.hash.hashVec3(WorldSpaces.sector.getPosition(x, y, z, tempPosition)));
|
|
60
69
|
return sector || false;
|
|
61
70
|
}
|
|
62
|
-
static remove(x, y, z) {
|
|
71
|
+
static remove(dimensionId, x, y, z) {
|
|
72
|
+
let dimension = WorldRegister.dimensions.get(dimensionId);
|
|
73
|
+
if (!dimension)
|
|
74
|
+
return false;
|
|
63
75
|
const position = WorldSpaces.sector.getPosition(x, y, z, tempPosition);
|
|
64
76
|
const sectorKey = WorldSpaces.hash.hashVec3(position);
|
|
65
|
-
const sector =
|
|
77
|
+
const sector = dimension.sectors.get(sectorKey);
|
|
66
78
|
if (!sector)
|
|
67
79
|
return false;
|
|
68
80
|
if (SectorPool._enabled)
|
|
69
81
|
SectorPool.returnSector(sector);
|
|
70
|
-
|
|
71
|
-
|
|
82
|
+
WorldDataHooks.sectors.onRemove([dimensionId, position.x, position.y, position.z], sector);
|
|
83
|
+
dimension.sectors.delete(sectorKey);
|
|
72
84
|
return true;
|
|
73
85
|
}
|
|
74
86
|
}
|
|
@@ -77,14 +89,6 @@ export class WorldRegister {
|
|
|
77
89
|
static _hooks = WorldDataHooks;
|
|
78
90
|
static dimensions = WorldRegisterDimensions;
|
|
79
91
|
static sectors = WorldRegisterSectors;
|
|
80
|
-
static _currentDimension;
|
|
81
|
-
static setDimension(dimensionId) {
|
|
82
|
-
let dimension = this.dimensions.get(dimensionId);
|
|
83
|
-
if (!dimension) {
|
|
84
|
-
dimension = this.dimensions.add(dimensionId);
|
|
85
|
-
}
|
|
86
|
-
this._currentDimension = dimension;
|
|
87
|
-
}
|
|
88
92
|
static clearAll() {
|
|
89
93
|
this._dimensions.clear();
|
|
90
94
|
}
|
package/World/WorldSpaces.d.ts
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
1
|
import { Vec3Array, Vector3Like } from "@amodx/math";
|
|
2
|
+
declare class WorldBounds {
|
|
3
|
+
static bounds: {
|
|
4
|
+
MinZ: number;
|
|
5
|
+
MaxZ: number;
|
|
6
|
+
MinX: number;
|
|
7
|
+
MaxX: number;
|
|
8
|
+
MinY: number;
|
|
9
|
+
MaxY: number;
|
|
10
|
+
};
|
|
11
|
+
static setWorldBounds(minX: number, maxX: number, minZ: number, maxZ: number, minY: number, maxY: number): void;
|
|
12
|
+
static inBounds(x: number, y: number, z: number): boolean;
|
|
13
|
+
static getWorldWidth(): number;
|
|
14
|
+
static getWorldDepth(): number;
|
|
15
|
+
static getWorldHeightY(): number;
|
|
16
|
+
static getWorldDimensions(): {
|
|
17
|
+
width: number;
|
|
18
|
+
depth: number;
|
|
19
|
+
height: number;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
2
22
|
declare class SectorSpace {
|
|
3
23
|
static power2Axes: Vector3Like;
|
|
4
24
|
static bounds: Vector3Like;
|
|
@@ -27,6 +47,7 @@ declare class Hash {
|
|
|
27
47
|
}
|
|
28
48
|
export declare class WorldSpaces {
|
|
29
49
|
static hash: typeof Hash;
|
|
50
|
+
static world: typeof WorldBounds;
|
|
30
51
|
static sector: typeof SectorSpace;
|
|
31
52
|
static section: typeof SectionSpace;
|
|
32
53
|
static voxel: typeof VoxelSpace;
|
package/World/WorldSpaces.js
CHANGED
|
@@ -4,6 +4,55 @@ import { Vector3Like } from "@amodx/math";
|
|
|
4
4
|
import { CubeHashVec3, CubeHashVec3Array, GetYXZOrderArrayIndex, } from "../Math/Indexing.js";
|
|
5
5
|
const tempPosition = Vector3Like.Create();
|
|
6
6
|
const tempPosition2 = Vector3Like.Create();
|
|
7
|
+
class WorldBounds {
|
|
8
|
+
static bounds = {
|
|
9
|
+
MinZ: -Number.MAX_SAFE_INTEGER,
|
|
10
|
+
MaxZ: Number.MAX_SAFE_INTEGER,
|
|
11
|
+
MinX: -Number.MAX_SAFE_INTEGER,
|
|
12
|
+
MaxX: Number.MAX_SAFE_INTEGER,
|
|
13
|
+
MinY: 0,
|
|
14
|
+
MaxY: 256,
|
|
15
|
+
};
|
|
16
|
+
static setWorldBounds(minX, maxX, minZ, maxZ, minY, maxY) {
|
|
17
|
+
this.bounds.MinX = minX;
|
|
18
|
+
this.bounds.MaxX = maxX;
|
|
19
|
+
this.bounds.MinX = minZ;
|
|
20
|
+
this.bounds.MaxZ = maxZ;
|
|
21
|
+
this.bounds.MinY = minY;
|
|
22
|
+
this.bounds.MaxY = maxY;
|
|
23
|
+
}
|
|
24
|
+
static inBounds(x, y, z) {
|
|
25
|
+
if (x < this.bounds.MinX)
|
|
26
|
+
return false;
|
|
27
|
+
if (y < this.bounds.MinY)
|
|
28
|
+
return false;
|
|
29
|
+
if (z < this.bounds.MinZ)
|
|
30
|
+
return false;
|
|
31
|
+
if (x > this.bounds.MaxX)
|
|
32
|
+
return false;
|
|
33
|
+
if (y > this.bounds.MaxY)
|
|
34
|
+
return false;
|
|
35
|
+
if (z > this.bounds.MaxZ)
|
|
36
|
+
return false;
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
static getWorldWidth() {
|
|
40
|
+
return this.bounds.MaxX - this.bounds.MinX;
|
|
41
|
+
}
|
|
42
|
+
static getWorldDepth() {
|
|
43
|
+
return this.bounds.MaxZ - this.bounds.MinZ;
|
|
44
|
+
}
|
|
45
|
+
static getWorldHeightY() {
|
|
46
|
+
return this.bounds.MaxY - this.bounds.MinY;
|
|
47
|
+
}
|
|
48
|
+
static getWorldDimensions() {
|
|
49
|
+
return {
|
|
50
|
+
width: this.getWorldWidth(),
|
|
51
|
+
depth: this.getWorldDepth(),
|
|
52
|
+
height: this.getWorldHeightY(),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
7
56
|
class SectorSpace {
|
|
8
57
|
static power2Axes = Vector3Like.Create();
|
|
9
58
|
static bounds = Vector3Like.Create();
|
|
@@ -69,21 +118,23 @@ class Hash {
|
|
|
69
118
|
}
|
|
70
119
|
export class WorldSpaces {
|
|
71
120
|
static hash = Hash;
|
|
121
|
+
static world = WorldBounds;
|
|
72
122
|
static sector = SectorSpace;
|
|
73
123
|
static section = SectionSpace;
|
|
74
124
|
static voxel = VoxelSpace;
|
|
75
125
|
}
|
|
76
126
|
EngineSettings.addEventListener("synced", (event) => {
|
|
77
|
-
event.detail.settings;
|
|
78
|
-
|
|
79
|
-
SectorSpace.power2Axes.
|
|
80
|
-
SectorSpace.power2Axes.
|
|
127
|
+
const { settings } = event.detail.settings;
|
|
128
|
+
WorldBounds.setWorldBounds(settings.world.minX, settings.world.maxX, settings.world.minZ, settings.world.maxZ, settings.world.minY, settings.world.maxY);
|
|
129
|
+
SectorSpace.power2Axes.x = settings.sectors.sectorXPow2;
|
|
130
|
+
SectorSpace.power2Axes.y = settings.sectors.sectorYPow2;
|
|
131
|
+
SectorSpace.power2Axes.z = settings.sectors.sectorZPow2;
|
|
81
132
|
SectorSpace.bounds.x = 1 << SectorSpace.power2Axes.x;
|
|
82
133
|
SectorSpace.bounds.y = 1 << SectorSpace.power2Axes.y;
|
|
83
134
|
SectorSpace.bounds.z = 1 << SectorSpace.power2Axes.z;
|
|
84
|
-
SectionSpace.power2Axes.x =
|
|
85
|
-
SectionSpace.power2Axes.y =
|
|
86
|
-
SectionSpace.power2Axes.z =
|
|
135
|
+
SectionSpace.power2Axes.x = settings.sections.sectionXPow2;
|
|
136
|
+
SectionSpace.power2Axes.y = settings.sections.sectionYPow2;
|
|
137
|
+
SectionSpace.power2Axes.z = settings.sections.sectionZPow2;
|
|
87
138
|
SectionSpace.bounds.x = 1 << SectionSpace.power2Axes.x;
|
|
88
139
|
SectionSpace.bounds.y = 1 << SectionSpace.power2Axes.y;
|
|
89
140
|
SectionSpace.bounds.z = 1 << SectionSpace.power2Axes.z;
|
package/package.json
CHANGED
package/Mesher/Geomtry/Mesh.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Vector3Like } from "@amodx/math";
|
|
2
|
-
export declare class Mesh {
|
|
3
|
-
buildBVH?: boolean | undefined;
|
|
4
|
-
indicieIndex: number;
|
|
5
|
-
minBounds: Vector3Like;
|
|
6
|
-
maxBounds: Vector3Like;
|
|
7
|
-
readonly buffer: number[];
|
|
8
|
-
readonly indices: number[];
|
|
9
|
-
constructor(buildBVH?: boolean | undefined);
|
|
10
|
-
clear(): void;
|
|
11
|
-
}
|
package/Mesher/Geomtry/Mesh.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Vector3Like } from "@amodx/math";
|
|
2
|
-
export class Mesh {
|
|
3
|
-
buildBVH;
|
|
4
|
-
indicieIndex = 0;
|
|
5
|
-
minBounds = Vector3Like.Create(Infinity, Infinity, Infinity);
|
|
6
|
-
maxBounds = Vector3Like.Create(-Infinity, -Infinity, -Infinity);
|
|
7
|
-
buffer = [];
|
|
8
|
-
indices = [];
|
|
9
|
-
constructor(buildBVH) {
|
|
10
|
-
this.buildBVH = buildBVH;
|
|
11
|
-
}
|
|
12
|
-
clear() {
|
|
13
|
-
this.buffer.length = 0;
|
|
14
|
-
this.indices.length = 0;
|
|
15
|
-
this.indicieIndex = 0;
|
|
16
|
-
this.minBounds.x = Infinity;
|
|
17
|
-
this.minBounds.y = Infinity;
|
|
18
|
-
this.minBounds.z = Infinity;
|
|
19
|
-
this.maxBounds.x = -Infinity;
|
|
20
|
-
this.maxBounds.y = -Infinity;
|
|
21
|
-
this.maxBounds.z = -Infinity;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/World/WorldBounds.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export declare class WorldBounds {
|
|
2
|
-
static bounds: {
|
|
3
|
-
MinZ: number;
|
|
4
|
-
MaxZ: number;
|
|
5
|
-
MinX: number;
|
|
6
|
-
MaxX: number;
|
|
7
|
-
MinY: number;
|
|
8
|
-
MaxY: number;
|
|
9
|
-
};
|
|
10
|
-
static setWorldBounds(minX: number, maxX: number, minZ: number, maxZ: number, minY: number, maxY: number): void;
|
|
11
|
-
static inBounds(x: number, y: number, z: number): boolean;
|
|
12
|
-
static getWorldWidth(): number;
|
|
13
|
-
static getWorldDepth(): number;
|
|
14
|
-
static getWorldHeightY(): number;
|
|
15
|
-
static getWorldDimensions(): {
|
|
16
|
-
width: number;
|
|
17
|
-
depth: number;
|
|
18
|
-
height: number;
|
|
19
|
-
};
|
|
20
|
-
}
|
package/World/WorldBounds.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { EngineSettings } from "../Settings/EngineSettings";
|
|
2
|
-
export class WorldBounds {
|
|
3
|
-
static bounds = {
|
|
4
|
-
MinZ: -Number.MAX_SAFE_INTEGER,
|
|
5
|
-
MaxZ: Number.MAX_SAFE_INTEGER,
|
|
6
|
-
MinX: -Number.MAX_SAFE_INTEGER,
|
|
7
|
-
MaxX: Number.MAX_SAFE_INTEGER,
|
|
8
|
-
MinY: 0,
|
|
9
|
-
MaxY: 256,
|
|
10
|
-
};
|
|
11
|
-
static setWorldBounds(minX, maxX, minZ, maxZ, minY, maxY) {
|
|
12
|
-
this.bounds.MinX = minX;
|
|
13
|
-
this.bounds.MaxX = maxX;
|
|
14
|
-
this.bounds.MinX = minZ;
|
|
15
|
-
this.bounds.MaxZ = maxZ;
|
|
16
|
-
this.bounds.MinY = minY;
|
|
17
|
-
this.bounds.MaxY = maxY;
|
|
18
|
-
}
|
|
19
|
-
static inBounds(x, y, z) {
|
|
20
|
-
if (x < this.bounds.MinX)
|
|
21
|
-
return false;
|
|
22
|
-
if (y < this.bounds.MinY)
|
|
23
|
-
return false;
|
|
24
|
-
if (z < this.bounds.MinZ)
|
|
25
|
-
return false;
|
|
26
|
-
if (x > this.bounds.MaxX)
|
|
27
|
-
return false;
|
|
28
|
-
if (y > this.bounds.MaxY)
|
|
29
|
-
return false;
|
|
30
|
-
if (z > this.bounds.MaxZ)
|
|
31
|
-
return false;
|
|
32
|
-
return true;
|
|
33
|
-
}
|
|
34
|
-
static getWorldWidth() {
|
|
35
|
-
return this.bounds.MaxX - this.bounds.MinX;
|
|
36
|
-
}
|
|
37
|
-
static getWorldDepth() {
|
|
38
|
-
return this.bounds.MaxZ - this.bounds.MinZ;
|
|
39
|
-
}
|
|
40
|
-
static getWorldHeightY() {
|
|
41
|
-
return this.bounds.MaxY - this.bounds.MinY;
|
|
42
|
-
}
|
|
43
|
-
static getWorldDimensions() {
|
|
44
|
-
return {
|
|
45
|
-
width: this.getWorldWidth(),
|
|
46
|
-
depth: this.getWorldDepth(),
|
|
47
|
-
height: this.getWorldHeightY(),
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
EngineSettings.addEventListener("synced", ({ detail: { settings: { settings }, }, }) => {
|
|
52
|
-
WorldBounds.setWorldBounds(settings.world.minX, settings.world.maxX, settings.world.minZ, settings.world.maxZ, settings.world.minY, settings.world.maxY);
|
|
53
|
-
});
|