@divinevoxel/vlox 0.0.71 → 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.
- package/Contexts/Base/Main/InitDataGenerator.js +0 -9
- package/Contexts/Base/Remote/DataSync.types.d.ts +0 -5
- package/Contexts/Base/Remote/InitDataSync.js +17 -31
- package/Init/StartConstructor.js +2 -4
- package/Init/StartWorld.js +0 -12
- package/Math/Indexing.d.ts +12 -3
- package/Math/Indexing.js +24 -15
- package/Mesher/Functions/CompactVoxelMesh.d.ts +1 -1
- package/Mesher/Functions/CompactVoxelMesh.js +3 -4
- package/Mesher/Functions/MeshSection.d.ts +1 -1
- package/Mesher/Functions/MeshSection.js +54 -60
- package/Mesher/Functions/MeshVoxel.js +20 -26
- package/Mesher/Geomtry/Buffers.d.ts +9 -8
- package/Mesher/Geomtry/Buffers.js +26 -58
- package/Mesher/Geomtry/Tools/MesherDataTools.d.ts +1 -1
- package/Mesher/Geomtry/Tools/MesherDataTools.js +1 -1
- package/Mesher/Geomtry/VoxelGeometryBuilder.js +107 -124
- package/Mesher/InitMesher.js +1 -10
- package/Mesher/InitTask.js +10 -4
- package/Mesher/Models/Common/BoundsFunctions.d.ts +1 -3
- package/Mesher/Models/Common/BoundsFunctions.js +0 -16
- package/Mesher/Models/Common/Calc/CalcConstants.js +14 -31
- package/Mesher/Models/Common/Calc/FaceDataCalc.d.ts +1 -7
- package/Mesher/Models/Common/Calc/FaceDataCalc.js +41 -50
- package/Mesher/Models/Nodes/Custom/Liquid/LiquidGeomtryNode.d.ts +1 -5
- package/Mesher/Models/Nodes/Custom/Liquid/LiquidGeomtryNode.js +30 -26
- package/Mesher/Models/Nodes/GeometryNode.d.ts +2 -4
- package/Mesher/Models/Nodes/GeometryNode.js +1 -2
- package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.d.ts +2 -6
- package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.js +37 -34
- package/Mesher/Models/Nodes/Ruled/QuadVoxelGeometryNode.d.ts +2 -6
- package/Mesher/Models/Nodes/Ruled/QuadVoxelGeometryNode.js +52 -51
- package/Mesher/Models/Nodes/Ruleless/RulelessBoxVoxelGeometryNode.d.ts +2 -6
- package/Mesher/Models/Nodes/Ruleless/RulelessBoxVoxelGeometryNode.js +18 -19
- package/Mesher/Models/Nodes/Ruleless/RulelessQuadVoxelGeometryNode.d.ts +2 -6
- package/Mesher/Models/Nodes/Ruleless/RulelessQuadVoxelGeometryNode.js +37 -40
- package/Mesher/Models/VoxelConstructor.d.ts +3 -4
- package/Mesher/Models/VoxelConstructor.js +23 -12
- package/Mesher/Models/{VoxelGeometryLookUp.d.ts → VoxelGeometryBuilderCacheSpace.d.ts} +8 -14
- package/Mesher/Models/{VoxelGeometryLookUp.js → VoxelGeometryBuilderCacheSpace.js} +49 -44
- package/Mesher/Models/VoxelModelConstructorRegister.js +3 -3
- package/Mesher/Tools/VoxelMeshBVHBuilder.d.ts +2 -9
- package/Mesher/Tools/VoxelMeshBVHBuilder.js +4 -16
- package/Mesher/Tools/VoxelMeshVertexStructCursor.d.ts +10 -0
- package/Mesher/Tools/VoxelMeshVertexStructCursor.js +10 -0
- package/Mesher/Tools/VoxelMesherDataTool.d.ts +8 -5
- package/Mesher/Tools/VoxelMesherDataTool.js +34 -13
- package/Models/Indexing/VoxelAOResultsIndex.d.ts +4 -4
- package/Models/Indexing/VoxelAOResultsIndex.js +15 -9
- package/Models/Indexing/VoxelFaceCullResultsIndex.d.ts +3 -3
- package/Models/Indexing/VoxelFaceCullResultsIndex.js +14 -9
- package/Models/Indexing/VoxelFaceTransparentResultsIndex.d.ts +1 -1
- package/Models/Indexing/VoxelFaceTransparentResultsIndex.js +1 -1
- package/Models/Rules/Functions/BuildRules.js +2 -2
- package/Tasks/IWG/Internal/Classes/Generator.js +1 -1
- package/Tasks/IWG/Internal/Functions/getSectorState.js +4 -7
- package/Tasks/IWG/Internal/Functions/runWorldUpdate.js +5 -6
- package/Tasks/IWG/Internal/IWGTasks.js +12 -21
- package/Tasks/Propagation/Flow/FlowManager.d.ts +0 -2
- package/Tasks/Propagation/Flow/FlowManager.js +86 -87
- package/Tasks/Propagation/Flow/WorldFlow.js +2 -3
- package/Tasks/Propagation/Illumanation/WorldRGB.js +1 -2
- package/Tasks/Update/InitTasks.d.ts +2 -1
- package/Tasks/Update/InitTasks.js +6 -6
- package/Tasks/Update/VoxelUpdate.js +15 -7
- package/Tasks/WorldGeneration/WorldGenBrush.js +1 -0
- package/Templates/Cursor/TemplateCursor.d.ts +1 -1
- package/Templates/Cursor/TemplateCursor.js +1 -1
- package/Templates/Functions/CreateTemplate.js +1 -1
- package/Templates/VoxelTemplate.js +6 -8
- package/Tools/Brush/Brush.d.ts +0 -2
- package/Tools/Brush/Brush.js +5 -6
- package/{Data/Cursor → Tools}/DataCursor.interface.d.ts +1 -1
- package/Util/Binary/BitArray.d.ts +4 -0
- package/Util/Binary/BitArray.js +16 -0
- package/Util/StringPalette.d.ts +1 -0
- package/Util/StringPalette.js +8 -0
- package/Voxels/Cursor/VoxelCursor.d.ts +6 -6
- package/Voxels/Cursor/VoxelCursor.interface.d.ts +10 -15
- package/Voxels/Cursor/VoxelCursor.interface.js +30 -50
- package/Voxels/Cursor/VoxelCursor.js +13 -12
- package/Voxels/Cursor/VoxelLightData.d.ts +3 -4
- package/Voxels/Cursor/VoxelLightData.js +8 -7
- package/Voxels/Data/VoxelPalettesRegister.d.ts +13 -0
- package/Voxels/Data/VoxelPalettesRegister.js +17 -0
- package/Voxels/Data/VoxelTag.types.d.ts +56 -0
- package/Voxels/Data/VoxelTag.types.js +23 -0
- package/Voxels/{State → Data}/VoxelTagStates.d.ts +2 -2
- package/Voxels/{State → Data}/VoxelTagStates.js +5 -5
- package/Voxels/Data/VoxelTagsRegister.d.ts +9 -0
- package/Voxels/Data/VoxelTagsRegister.js +32 -0
- package/Voxels/Functions/BuildStateData.js +3 -3
- package/Voxels/Functions/BuildTagAndPaletteData.d.ts +13 -0
- package/Voxels/Functions/BuildTagAndPaletteData.js +57 -0
- package/Voxels/Indexes/VoxelIndex.js +3 -3
- package/Voxels/InitVoxelData.js +20 -61
- package/Voxels/State/Schema/StateSchema.d.ts +1 -1
- package/Voxels/Types/Voxel.types.d.ts +2 -42
- package/Voxels/Types/Voxel.types.js +0 -15
- package/Voxels/Types/VoxelModelCompiledData.types.d.ts +11 -13
- package/Voxels/Types/VoxelSubstances.types.d.ts +2 -15
- package/Voxels/Types/VoxelSubstances.types.js +1 -9
- package/World/Archive/Functions/ArchiveArea.js +2 -6
- package/World/Archive/Functions/ArchiveSector.js +14 -28
- package/World/Archive/Functions/ImportSector.js +27 -34
- package/World/Cursor/SectionCursor.d.ts +2 -1
- package/World/Cursor/SectionCursor.js +8 -2
- package/World/Cursor/SectorCursor.d.ts +2 -1
- package/World/Cursor/SectorCursor.js +5 -2
- package/World/Cursor/WorldCursor.d.ts +1 -1
- package/World/Cursor/WorldCursor.js +6 -2
- package/World/Cursor/WorldVoxelCursor.d.ts +7 -7
- package/World/Cursor/WorldVoxelCursor.js +20 -24
- package/World/Section/Section.d.ts +20 -8
- package/World/Section/Section.js +65 -9
- package/World/Sector/Sector.d.ts +13 -6
- package/World/Sector/Sector.js +30 -9
- package/World/Sector/SectorHeightMap.js +1 -3
- package/World/Sector/SectorState.d.ts +13 -0
- package/World/Sector/SectorState.js +15 -0
- package/World/WorldSpaces.d.ts +2 -0
- package/World/WorldSpaces.js +7 -1
- package/package.json +1 -1
- package/Data/Register/MappedDataRegister.d.ts +0 -5
- package/Data/Register/MappedDataRegister.js +0 -9
- package/Data/Register/MappedRegisterBase.d.ts +0 -14
- package/Data/Register/MappedRegisterBase.js +0 -50
- package/Data/Structs/StructBuilder.d.ts +0 -34
- package/Data/Structs/StructBuilder.js +0 -157
- package/Data/Structs/StructBuilder.types.d.ts +0 -30
- package/Data/Structs/StructBuilder.types.js +0 -1
- package/Tools/Data/SubstanceDataTool.d.ts +0 -13
- package/Tools/Data/SubstanceDataTool.js +0 -51
- package/Voxels/Palettes/MaterialPalette.d.ts +0 -9
- package/Voxels/Palettes/MaterialPalette.js +0 -11
- package/Voxels/Palettes/SubstancePalette.d.ts +0 -9
- package/Voxels/Palettes/SubstancePalette.js +0 -11
- package/Voxels/Palettes/VoxelPalette.d.ts +0 -11
- package/Voxels/Palettes/VoxelPalette.js +0 -15
- package/Voxels/Segments/MaterialDataGenerator.d.ts +0 -6
- package/Voxels/Segments/MaterialDataGenerator.js +0 -12
- package/Voxels/Segments/SubstanceDataGenerator.d.ts +0 -6
- package/Voxels/Segments/SubstanceDataGenerator.js +0 -35
- package/Voxels/Segments/VoxelDataGenerator.d.ts +0 -10
- package/Voxels/Segments/VoxelDataGenerator.js +0 -56
- package/Voxels/Structs/Builder/SubstanceStructBuilder.d.ts +0 -2
- package/Voxels/Structs/Builder/SubstanceStructBuilder.js +0 -42
- package/Voxels/Structs/Builder/VoxelStructBuilder.d.ts +0 -2
- package/Voxels/Structs/Builder/VoxelStructBuilder.js +0 -68
- package/Voxels/Structs/SubstanceStruct.d.ts +0 -17
- package/Voxels/Structs/SubstanceStruct.js +0 -17
- package/Voxels/Structs/VoxelStruct.d.ts +0 -27
- package/Voxels/Structs/VoxelStruct.js +0 -29
- package/World/Section/SectionHeightMap.d.ts +0 -10
- package/World/Section/SectionHeightMap.js +0 -39
- package/World/Section/SectionStruct.d.ts +0 -8
- package/World/Section/SectionStruct.js +0 -29
- package/World/Section/SectionStructProperties.d.ts +0 -10
- package/World/Section/SectionStructProperties.js +0 -11
- package/World/Sector/SectorStruct.d.ts +0 -1
- package/World/Sector/SectorStruct.js +0 -46
- package/World/Sector/SectorStructIds.d.ts +0 -13
- package/World/Sector/SectorStructIds.js +0 -14
- /package/{Data/Cursor → Tools}/DataCursor.interface.js +0 -0
- /package/{Data/Functions → Util/Binary}/Palettes.d.ts +0 -0
- /package/{Data/Functions → Util/Binary}/Palettes.js +0 -0
- /package/Voxels/{VoxelLevelReader.d.ts → Cursor/VoxelLevelReader.d.ts} +0 -0
- /package/Voxels/{VoxelLevelReader.js → Cursor/VoxelLevelReader.js} +0 -0
package/World/Section/Section.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { RemoteBinaryStruct } from "@amodx/binary/";
|
|
2
1
|
import { WorldSpaces } from "../WorldSpaces.js";
|
|
3
2
|
import { Sector } from "../Sector/Sector.js";
|
|
3
|
+
import { getBitArrayIndex, setBitArrayIndex, } from "../../Util/Binary/BitArray.js";
|
|
4
4
|
function forceMultipleOf2(n) {
|
|
5
5
|
return n % 2 === 0 ? n : n + 1;
|
|
6
6
|
}
|
|
@@ -10,7 +10,20 @@ export class Section {
|
|
|
10
10
|
index;
|
|
11
11
|
static GetBufferSize() {
|
|
12
12
|
const voxelSize = WorldSpaces.section.volumne;
|
|
13
|
-
|
|
13
|
+
const height = WorldSpaces.section.bounds.y;
|
|
14
|
+
return forceMultipleOf2(
|
|
15
|
+
//-----
|
|
16
|
+
//voxelMap
|
|
17
|
+
height / 8 +
|
|
18
|
+
//dirtyMap
|
|
19
|
+
height / 8 +
|
|
20
|
+
//-----
|
|
21
|
+
//cache
|
|
22
|
+
voxelSize / 8 +
|
|
23
|
+
//exposed
|
|
24
|
+
voxelSize * 2 +
|
|
25
|
+
//-----
|
|
26
|
+
//voxel data
|
|
14
27
|
//ids
|
|
15
28
|
voxelSize * 2 +
|
|
16
29
|
//light
|
|
@@ -25,13 +38,18 @@ export class Section {
|
|
|
25
38
|
voxelSize * 2);
|
|
26
39
|
}
|
|
27
40
|
static GetArrayStartIndex(index) {
|
|
28
|
-
return
|
|
29
|
-
Sector.GetHeaderSize() +
|
|
30
|
-
forceMultipleOf2(Section.StateStruct.structSize));
|
|
41
|
+
return index * Section.GetBufferSize() + Sector.GetHeaderSize();
|
|
31
42
|
}
|
|
32
43
|
static CreateNew(index, sectorBuffer) {
|
|
33
44
|
const voxelSize = WorldSpaces.section.volumne;
|
|
34
45
|
let bufferStart = this.GetArrayStartIndex(index);
|
|
46
|
+
const height = WorldSpaces.section.bounds.y;
|
|
47
|
+
const voxelMap = new Uint8Array(sectorBuffer, bufferStart, height / 8);
|
|
48
|
+
bufferStart += height / 8;
|
|
49
|
+
const dirtyMap = new Uint8Array(sectorBuffer, bufferStart, height / 8);
|
|
50
|
+
bufferStart += height / 8;
|
|
51
|
+
const buried = new Uint8Array(sectorBuffer, bufferStart, voxelSize / 8);
|
|
52
|
+
bufferStart += voxelSize / 8;
|
|
35
53
|
const ids = new Uint16Array(sectorBuffer, bufferStart, voxelSize);
|
|
36
54
|
bufferStart += voxelSize * 2;
|
|
37
55
|
const light = new Uint16Array(sectorBuffer, bufferStart, voxelSize);
|
|
@@ -45,6 +63,9 @@ export class Section {
|
|
|
45
63
|
const level = new Uint8Array(sectorBuffer, bufferStart, voxelSize);
|
|
46
64
|
bufferStart += voxelSize;
|
|
47
65
|
return {
|
|
66
|
+
voxelMap,
|
|
67
|
+
dirtyMap,
|
|
68
|
+
buried,
|
|
48
69
|
ids,
|
|
49
70
|
light,
|
|
50
71
|
level,
|
|
@@ -56,12 +77,12 @@ export class Section {
|
|
|
56
77
|
static toObject(sector, index, data) {
|
|
57
78
|
return new Section(sector, index, data);
|
|
58
79
|
}
|
|
59
|
-
static StateStruct = new RemoteBinaryStruct("section-tags");
|
|
60
|
-
sectionState;
|
|
61
80
|
constructor(sector, index, data) {
|
|
62
81
|
this.sector = sector;
|
|
63
82
|
this.index = index;
|
|
64
|
-
this.
|
|
83
|
+
this.voxelMap = data.voxelMap;
|
|
84
|
+
this.dirtyMap = data.dirtyMap;
|
|
85
|
+
this.buried = data.buried;
|
|
65
86
|
this.ids = data.ids;
|
|
66
87
|
this.level = data.level;
|
|
67
88
|
this.light = data.light;
|
|
@@ -76,8 +97,43 @@ export class Section {
|
|
|
76
97
|
position[2] = this.sector.position[2];
|
|
77
98
|
return position;
|
|
78
99
|
}
|
|
79
|
-
|
|
100
|
+
getBuried(index) {
|
|
101
|
+
return getBitArrayIndex(this.buried, index) == 1;
|
|
102
|
+
}
|
|
103
|
+
setBuried(index, value) {
|
|
104
|
+
return setBitArrayIndex(this.buried, index, value ? 1 : 0);
|
|
105
|
+
}
|
|
106
|
+
setHasVoxel(y, hasVoxel) {
|
|
107
|
+
return setBitArrayIndex(this.voxelMap, y, hasVoxel ? 1 : 0);
|
|
108
|
+
}
|
|
109
|
+
getHasVoxel(y) {
|
|
110
|
+
return getBitArrayIndex(this.voxelMap, y) == 1;
|
|
111
|
+
}
|
|
112
|
+
setHasVoxelDirty(y, dirty) {
|
|
113
|
+
return setBitArrayIndex(this.dirtyMap, y, dirty ? 1 : 0);
|
|
114
|
+
}
|
|
115
|
+
getHasVoxelDirty(y) {
|
|
116
|
+
return getBitArrayIndex(this.dirtyMap, y) == 1;
|
|
117
|
+
}
|
|
118
|
+
getMinMax() {
|
|
119
|
+
let min = Infinity;
|
|
120
|
+
let max = -Infinity;
|
|
121
|
+
let i = WorldSpaces.section.bounds.y;
|
|
122
|
+
while (i--) {
|
|
123
|
+
if (this.getHasVoxel(i) || this.getHasVoxelDirty(i)) {
|
|
124
|
+
if (i < min)
|
|
125
|
+
min = i;
|
|
126
|
+
if (i > max)
|
|
127
|
+
max = i;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return [min, max];
|
|
131
|
+
}
|
|
132
|
+
toJSON() {
|
|
80
133
|
return {
|
|
134
|
+
voxelMap: this.voxelMap,
|
|
135
|
+
dirtyMap: this.dirtyMap,
|
|
136
|
+
buried: this.buried,
|
|
81
137
|
ids: this.ids,
|
|
82
138
|
light: this.light,
|
|
83
139
|
level: this.level,
|
package/World/Sector/Sector.d.ts
CHANGED
|
@@ -1,23 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Section, VoxelDataArrays } from "../Section/Section.js";
|
|
1
|
+
import { Section, SectionData } from "../Section/Section.js";
|
|
3
2
|
import { Vec3Array } from "@amodx/math";
|
|
3
|
+
import { SectorStateFlags, SectorTimestampFlags } from "./SectorState.js";
|
|
4
4
|
export interface SectorData {
|
|
5
5
|
position: Vec3Array;
|
|
6
6
|
buffer: ArrayBufferLike;
|
|
7
|
-
|
|
7
|
+
/**Array of timestamps for the sector */
|
|
8
|
+
timeStampArray: Uint32Array;
|
|
9
|
+
/**Array of bit flags for the sector*/
|
|
10
|
+
flagArray: Uint8Array;
|
|
11
|
+
sections: SectionData[];
|
|
8
12
|
}
|
|
9
13
|
export interface Sector extends SectorData {
|
|
10
14
|
}
|
|
11
15
|
export declare class Sector {
|
|
12
|
-
static
|
|
16
|
+
static FlagIds: typeof SectorStateFlags;
|
|
17
|
+
static TimeStampIds: typeof SectorTimestampFlags;
|
|
13
18
|
static GetHeaderSize(): number;
|
|
14
19
|
static GetBufferSize(): number;
|
|
15
20
|
static CreateNew(): SectorData;
|
|
16
21
|
sections: Section[];
|
|
17
22
|
bufferView: Uint8Array;
|
|
18
|
-
sectorState: DataView;
|
|
19
|
-
position: Vec3Array;
|
|
20
23
|
constructor(data: SectorData);
|
|
21
24
|
getSection(y: number): Section;
|
|
25
|
+
setBitFlag(index: number, value: boolean): void;
|
|
26
|
+
getBitFlag(index: number): boolean;
|
|
27
|
+
setTimeStamp(index: number, value: number): void;
|
|
28
|
+
getTimeStamp(index: number): number;
|
|
22
29
|
toJSON(): SectorData;
|
|
23
30
|
}
|
package/World/Sector/Sector.js
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
import { RemoteBinaryStruct } from "@amodx/binary/";
|
|
2
1
|
import { Section } from "../Section/Section.js";
|
|
3
2
|
import { WorldSpaces } from "../WorldSpaces";
|
|
3
|
+
import { getBitArrayIndex, setBitArrayIndex, } from "../../Util/Binary/BitArray.js";
|
|
4
|
+
import { SectorStateFlags, SectorTimestampFlags } from "./SectorState.js";
|
|
4
5
|
function forceMultipleOf2(n) {
|
|
5
6
|
return n % 2 === 0 ? n : n + 1;
|
|
6
7
|
}
|
|
7
8
|
export class Sector {
|
|
8
|
-
static
|
|
9
|
+
static FlagIds = SectorStateFlags;
|
|
10
|
+
static TimeStampIds = SectorTimestampFlags;
|
|
9
11
|
static GetHeaderSize() {
|
|
10
|
-
return forceMultipleOf2(
|
|
12
|
+
return forceMultipleOf2(
|
|
13
|
+
//12 bytes fot flags
|
|
14
|
+
12 +
|
|
15
|
+
//12 * 4 bytes for time stamps
|
|
16
|
+
12 * 4);
|
|
11
17
|
}
|
|
12
18
|
static GetBufferSize() {
|
|
13
19
|
const totalSections = WorldSpaces.sector.bounds.y / WorldSpaces.section.bounds.y;
|
|
@@ -15,8 +21,8 @@ export class Sector {
|
|
|
15
21
|
}
|
|
16
22
|
static CreateNew() {
|
|
17
23
|
const buffer = new SharedArrayBuffer(this.GetBufferSize());
|
|
18
|
-
|
|
19
|
-
|
|
24
|
+
const flagArray = new Uint8Array(buffer, 0, 12);
|
|
25
|
+
const timeStampArray = new Uint32Array(buffer, 12, 12 * 4);
|
|
20
26
|
const sections = [];
|
|
21
27
|
const totalSections = WorldSpaces.sector.bounds.y / WorldSpaces.section.bounds.y;
|
|
22
28
|
for (let i = 0; i < totalSections; i++) {
|
|
@@ -25,16 +31,17 @@ export class Sector {
|
|
|
25
31
|
return {
|
|
26
32
|
position: [0, 0, 0],
|
|
27
33
|
buffer,
|
|
34
|
+
flagArray,
|
|
35
|
+
timeStampArray,
|
|
28
36
|
sections,
|
|
29
37
|
};
|
|
30
38
|
}
|
|
31
39
|
sections = [];
|
|
32
40
|
bufferView;
|
|
33
|
-
sectorState;
|
|
34
|
-
position;
|
|
35
41
|
constructor(data) {
|
|
36
42
|
this.position = data.position;
|
|
37
|
-
this.
|
|
43
|
+
this.flagArray = data.flagArray;
|
|
44
|
+
this.timeStampArray = data.timeStampArray;
|
|
38
45
|
this.buffer = data.buffer;
|
|
39
46
|
this.bufferView = new Uint8Array(data.buffer);
|
|
40
47
|
for (let i = 0; i < data.sections.length; i++) {
|
|
@@ -46,14 +53,28 @@ export class Sector {
|
|
|
46
53
|
const index = ry / WorldSpaces.section.bounds.y;
|
|
47
54
|
return this.sections[index];
|
|
48
55
|
}
|
|
56
|
+
setBitFlag(index, value) {
|
|
57
|
+
setBitArrayIndex(this.flagArray, index, value ? 1 : 0);
|
|
58
|
+
}
|
|
59
|
+
getBitFlag(index) {
|
|
60
|
+
return getBitArrayIndex(this.flagArray, index) == 1;
|
|
61
|
+
}
|
|
62
|
+
setTimeStamp(index, value) {
|
|
63
|
+
this.timeStampArray[index] = value;
|
|
64
|
+
}
|
|
65
|
+
getTimeStamp(index) {
|
|
66
|
+
return this.timeStampArray[index];
|
|
67
|
+
}
|
|
49
68
|
toJSON() {
|
|
50
69
|
const sections = [];
|
|
51
70
|
for (const section of this.sections) {
|
|
52
|
-
sections.push(section.
|
|
71
|
+
sections.push(section.toJSON());
|
|
53
72
|
}
|
|
54
73
|
return {
|
|
55
74
|
position: this.position,
|
|
56
75
|
buffer: this.buffer,
|
|
76
|
+
flagArray: this.flagArray,
|
|
77
|
+
timeStampArray: this.timeStampArray,
|
|
57
78
|
sections,
|
|
58
79
|
};
|
|
59
80
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { $2dMooreNeighborhood } from "../../Math/CardinalNeighbors";
|
|
2
|
-
import { SectionHeightMap } from "../Section/SectionHeightMap";
|
|
3
2
|
import { WorldRegister } from "../WorldRegister";
|
|
4
3
|
import { WorldSpaces } from "../WorldSpaces";
|
|
5
4
|
export class SectorHeightMap {
|
|
@@ -32,9 +31,8 @@ export class SectorHeightMap {
|
|
|
32
31
|
const section = sector.sections[i];
|
|
33
32
|
if (!section)
|
|
34
33
|
continue;
|
|
35
|
-
SectionHeightMap.setSection(section);
|
|
36
34
|
const sectionPOS = y + i * WorldSpaces.section.bounds.y;
|
|
37
|
-
let [sectionMin, sectionMax] =
|
|
35
|
+
let [sectionMin, sectionMax] = section.getMinMax();
|
|
38
36
|
if (Math.abs(sectionMax) == Infinity)
|
|
39
37
|
continue;
|
|
40
38
|
sectionMax = sectionPOS + sectionMax;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare enum SectorStateFlags {
|
|
2
|
+
isWorldGenDone = 0,
|
|
3
|
+
isWorldDecorDone = 1,
|
|
4
|
+
isWorldPropagationDone = 2,
|
|
5
|
+
isWorldSunDone = 3,
|
|
6
|
+
isDirty = 4,
|
|
7
|
+
isStored = 5,
|
|
8
|
+
persistent = 6
|
|
9
|
+
}
|
|
10
|
+
export declare enum SectorTimestampFlags {
|
|
11
|
+
lastSaveTimestamp = 0,
|
|
12
|
+
lastAnalyzerUpdateTimestamp = 1
|
|
13
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export var SectorStateFlags;
|
|
2
|
+
(function (SectorStateFlags) {
|
|
3
|
+
SectorStateFlags[SectorStateFlags["isWorldGenDone"] = 0] = "isWorldGenDone";
|
|
4
|
+
SectorStateFlags[SectorStateFlags["isWorldDecorDone"] = 1] = "isWorldDecorDone";
|
|
5
|
+
SectorStateFlags[SectorStateFlags["isWorldPropagationDone"] = 2] = "isWorldPropagationDone";
|
|
6
|
+
SectorStateFlags[SectorStateFlags["isWorldSunDone"] = 3] = "isWorldSunDone";
|
|
7
|
+
SectorStateFlags[SectorStateFlags["isDirty"] = 4] = "isDirty";
|
|
8
|
+
SectorStateFlags[SectorStateFlags["isStored"] = 5] = "isStored";
|
|
9
|
+
SectorStateFlags[SectorStateFlags["persistent"] = 6] = "persistent";
|
|
10
|
+
})(SectorStateFlags || (SectorStateFlags = {}));
|
|
11
|
+
export var SectorTimestampFlags;
|
|
12
|
+
(function (SectorTimestampFlags) {
|
|
13
|
+
SectorTimestampFlags[SectorTimestampFlags["lastSaveTimestamp"] = 0] = "lastSaveTimestamp";
|
|
14
|
+
SectorTimestampFlags[SectorTimestampFlags["lastAnalyzerUpdateTimestamp"] = 1] = "lastAnalyzerUpdateTimestamp";
|
|
15
|
+
})(SectorTimestampFlags || (SectorTimestampFlags = {}));
|
package/World/WorldSpaces.d.ts
CHANGED
|
@@ -38,7 +38,9 @@ declare class VoxelSpace {
|
|
|
38
38
|
static bounds: Vector3Like;
|
|
39
39
|
static getPosition(x: number, y: number, z: number, refPosition?: Vector3Like): Vector3Like;
|
|
40
40
|
static getPositionVec3Array(x: number, y: number, z: number, refPosition?: Vec3Array): Vec3Array;
|
|
41
|
+
static getPositionFromIndex(index: number, refPosition?: Vector3Like): Vector3Like;
|
|
41
42
|
static getIndex(x: number, y: number, z: number): number;
|
|
43
|
+
static getIndexFromPosition(x: number, y: number, z: number): number;
|
|
42
44
|
}
|
|
43
45
|
declare class Hash {
|
|
44
46
|
static hashVec3(vector3: Vector3Like): string;
|
package/World/WorldSpaces.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//types
|
|
2
2
|
import { EngineSettings } from "../Settings/EngineSettings.js";
|
|
3
3
|
import { Vector3Like } from "@amodx/math";
|
|
4
|
-
import { CubeHashVec3, CubeHashVec3Array, GetYXZOrderArrayIndex, } from "../Math/Indexing.js";
|
|
4
|
+
import { CubeHashVec3, CubeHashVec3Array, GetYXZOrderArrayIndex, GetYXZOrderArrayPositionVec3, } from "../Math/Indexing.js";
|
|
5
5
|
const tempPosition = Vector3Like.Create();
|
|
6
6
|
const tempPosition2 = Vector3Like.Create();
|
|
7
7
|
class WorldBounds {
|
|
@@ -100,10 +100,16 @@ class VoxelSpace {
|
|
|
100
100
|
refPosition[2] = z - refPosition[2];
|
|
101
101
|
return refPosition;
|
|
102
102
|
}
|
|
103
|
+
static getPositionFromIndex(index, refPosition = Vector3Like.Create()) {
|
|
104
|
+
return GetYXZOrderArrayPositionVec3(index, SectionSpace.bounds.x, SectionSpace.bounds.y, SectionSpace.bounds.z, refPosition);
|
|
105
|
+
}
|
|
103
106
|
static getIndex(x, y, z) {
|
|
104
107
|
const position = this.getPosition(x, y, z, tempPosition);
|
|
105
108
|
return GetYXZOrderArrayIndex(position.x, position.y, position.z, SectionSpace.bounds.x, SectionSpace.bounds.y, SectionSpace.bounds.z);
|
|
106
109
|
}
|
|
110
|
+
static getIndexFromPosition(x, y, z) {
|
|
111
|
+
return GetYXZOrderArrayIndex(x, y, z, SectionSpace.bounds.x, SectionSpace.bounds.y, SectionSpace.bounds.z);
|
|
112
|
+
}
|
|
107
113
|
}
|
|
108
114
|
class Hash {
|
|
109
115
|
static hashVec3(vector3) {
|
package/package.json
CHANGED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { MappedRegisterBase } from "./MappedRegisterBase.js";
|
|
2
|
-
export class MappedDataRegister {
|
|
3
|
-
static stringMaps = new MappedRegisterBase();
|
|
4
|
-
static objectMaps = new MappedRegisterBase();
|
|
5
|
-
}
|
|
6
|
-
MappedDataRegister.stringMaps.addSegment("voxel");
|
|
7
|
-
MappedDataRegister.objectMaps.addSegment("voxel");
|
|
8
|
-
MappedDataRegister.stringMaps.addSegment("substance");
|
|
9
|
-
MappedDataRegister.objectMaps.addSegment("substance");
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
declare class MappedRegisterSegment<Data> extends EventTarget {
|
|
2
|
-
entries: Map<string, Data[]>;
|
|
3
|
-
onEntryAdded(id: string, run: (data: Data[]) => void): void;
|
|
4
|
-
add(id: string, data: Data[]): void;
|
|
5
|
-
get(id: string): Data[] | undefined;
|
|
6
|
-
}
|
|
7
|
-
export declare class MappedRegisterBase<Data> {
|
|
8
|
-
segments: Map<string, MappedRegisterSegment<Data>>;
|
|
9
|
-
addSegment(id: string): MappedRegisterSegment<Data>;
|
|
10
|
-
getSegment(id: string): MappedRegisterSegment<Data>;
|
|
11
|
-
sync(segment: string, id: string, value: Data[]): void;
|
|
12
|
-
get(segment: string, id: string, index: number): Data | null;
|
|
13
|
-
}
|
|
14
|
-
export {};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
const getSyncId = (id) => `entry-synced-${id}`;
|
|
2
|
-
class MappedRegisterSegment extends EventTarget {
|
|
3
|
-
entries = new Map();
|
|
4
|
-
onEntryAdded(id, run) {
|
|
5
|
-
const entrySyncedId = getSyncId(id);
|
|
6
|
-
const listener = () => {
|
|
7
|
-
run(this.entries.get(id));
|
|
8
|
-
this.removeEventListener(entrySyncedId, listener);
|
|
9
|
-
};
|
|
10
|
-
this.addEventListener(entrySyncedId, listener);
|
|
11
|
-
}
|
|
12
|
-
add(id, data) {
|
|
13
|
-
this.entries.set(id, data);
|
|
14
|
-
this.dispatchEvent(new Event(getSyncId(id)));
|
|
15
|
-
}
|
|
16
|
-
get(id) {
|
|
17
|
-
return this.entries.get(id);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
export class MappedRegisterBase {
|
|
21
|
-
segments = new Map();
|
|
22
|
-
addSegment(id) {
|
|
23
|
-
if (this.segments.has(id))
|
|
24
|
-
return this.segments.get(id);
|
|
25
|
-
const newSegment = new MappedRegisterSegment();
|
|
26
|
-
this.segments.set(id, newSegment);
|
|
27
|
-
return newSegment;
|
|
28
|
-
}
|
|
29
|
-
getSegment(id) {
|
|
30
|
-
const segment = this.segments.get(id);
|
|
31
|
-
if (!segment)
|
|
32
|
-
throw new Error(`Segment with id ${id} does not exist`);
|
|
33
|
-
return segment;
|
|
34
|
-
}
|
|
35
|
-
sync(segment, id, value) {
|
|
36
|
-
const segmentMap = this.addSegment(segment);
|
|
37
|
-
segmentMap.add(id, value);
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
get(segment, id, index) {
|
|
41
|
-
const segmentMap = this.segments.get(segment);
|
|
42
|
-
if (!segmentMap)
|
|
43
|
-
return null;
|
|
44
|
-
const mapped = segmentMap.get(id);
|
|
45
|
-
if (!mapped) {
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
return mapped[index];
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { TagBuilderNodes } from "Data/Structs/StructBuilder.types.js";
|
|
2
|
-
import { BinaryStructData, BinraryStructBase } from "@amodx/binary/";
|
|
3
|
-
import { BinaryStruct } from "@amodx/binary/";
|
|
4
|
-
export declare class StructBuilder {
|
|
5
|
-
id: string;
|
|
6
|
-
dataSegment: string;
|
|
7
|
-
_built: boolean;
|
|
8
|
-
_nodeMap: Map<string, TagBuilderNodes>;
|
|
9
|
-
_stringMaps: Map<string, {
|
|
10
|
-
count: number;
|
|
11
|
-
found: Record<string, number>;
|
|
12
|
-
map: string[];
|
|
13
|
-
allowedComms: string[];
|
|
14
|
-
}>;
|
|
15
|
-
_objectMaps: Map<string, {
|
|
16
|
-
count: number;
|
|
17
|
-
found: Record<string, number>;
|
|
18
|
-
map: any[];
|
|
19
|
-
allowedComms: string[];
|
|
20
|
-
}>;
|
|
21
|
-
_defaults: Map<string, number>;
|
|
22
|
-
_initData: BinaryStructData;
|
|
23
|
-
constructor(id: string, dataSegment: string);
|
|
24
|
-
addNode(node: TagBuilderNodes | TagBuilderNodes[]): void;
|
|
25
|
-
getNode(id: string): TagBuilderNodes | undefined;
|
|
26
|
-
setDefaults(tagManager: BinraryStructBase): void;
|
|
27
|
-
hasNode(id: string): boolean;
|
|
28
|
-
setNode(id: string, value: any, tagManager: BinraryStructBase): false | undefined;
|
|
29
|
-
build(totalTagIndexes?: number): BinaryStruct;
|
|
30
|
-
getMaps(): {
|
|
31
|
-
objectMaps: Record<string, any[]>;
|
|
32
|
-
stringMaps: Record<string, string[]>;
|
|
33
|
-
};
|
|
34
|
-
}
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import { BinaryNumberTypes, } from "@amodx/binary/";
|
|
2
|
-
import { BinaryStruct } from "@amodx/binary/";
|
|
3
|
-
export class StructBuilder {
|
|
4
|
-
id;
|
|
5
|
-
dataSegment;
|
|
6
|
-
_built = false;
|
|
7
|
-
_nodeMap = new Map();
|
|
8
|
-
_stringMaps = new Map();
|
|
9
|
-
_objectMaps = new Map();
|
|
10
|
-
_defaults = new Map();
|
|
11
|
-
_initData;
|
|
12
|
-
constructor(id, dataSegment) {
|
|
13
|
-
this.id = id;
|
|
14
|
-
this.dataSegment = dataSegment;
|
|
15
|
-
}
|
|
16
|
-
addNode(node) {
|
|
17
|
-
if (Array.isArray(node)) {
|
|
18
|
-
for (const n of node) {
|
|
19
|
-
this._nodeMap.set(n.id, n);
|
|
20
|
-
}
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
this._nodeMap.set(node.id, node);
|
|
24
|
-
}
|
|
25
|
-
getNode(id) {
|
|
26
|
-
return this._nodeMap.get(id);
|
|
27
|
-
}
|
|
28
|
-
setDefaults(tagManager) {
|
|
29
|
-
for (const [key, node] of this._nodeMap) {
|
|
30
|
-
const defaultValue = this._defaults.get(key);
|
|
31
|
-
if (!defaultValue)
|
|
32
|
-
continue;
|
|
33
|
-
tagManager.setProperty(key, Number(defaultValue));
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
hasNode(id) {
|
|
37
|
-
return this._nodeMap.has(id);
|
|
38
|
-
}
|
|
39
|
-
setNode(id, value, tagManager) {
|
|
40
|
-
const node = this.getNode(id);
|
|
41
|
-
if (!node)
|
|
42
|
-
return;
|
|
43
|
-
if (node.type == "number") {
|
|
44
|
-
tagManager.setProperty(node.id, Number(value));
|
|
45
|
-
}
|
|
46
|
-
if (node.type == "boolean") {
|
|
47
|
-
tagManager.setProperty(node.id, Number(value));
|
|
48
|
-
}
|
|
49
|
-
if (node.type == "number-array") {
|
|
50
|
-
if (!Array.isArray(value))
|
|
51
|
-
return false;
|
|
52
|
-
let i = value.length;
|
|
53
|
-
while (i--) {
|
|
54
|
-
tagManager.setArrayPropertyValue(node.id, i, value[i]);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
if (node.type == "string-map") {
|
|
58
|
-
const data = this._stringMaps.get(node.id);
|
|
59
|
-
if (!data)
|
|
60
|
-
return false;
|
|
61
|
-
const v = String(value).trim();
|
|
62
|
-
if (data.found[v] === undefined) {
|
|
63
|
-
data.map.push(v);
|
|
64
|
-
data.found[v] = data.count;
|
|
65
|
-
data.count++;
|
|
66
|
-
}
|
|
67
|
-
tagManager.setProperty(node.id, data.found[v]);
|
|
68
|
-
}
|
|
69
|
-
if (node.type == "object-map") {
|
|
70
|
-
const data = this._objectMaps.get(node.id);
|
|
71
|
-
if (!data)
|
|
72
|
-
return false;
|
|
73
|
-
const v = JSON.stringify(value);
|
|
74
|
-
if (data.found[v] === undefined) {
|
|
75
|
-
data.map[data.count] = value;
|
|
76
|
-
data.found[v] = data.count;
|
|
77
|
-
data.count++;
|
|
78
|
-
}
|
|
79
|
-
tagManager.setProperty(node.id, data.found[v]);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
build(totalTagIndexes = 0) {
|
|
83
|
-
const tags = new BinaryStruct(this.id);
|
|
84
|
-
for (const [key, node] of this._nodeMap) {
|
|
85
|
-
if (node.type == "number") {
|
|
86
|
-
tags.registerProperty({
|
|
87
|
-
id: node.id,
|
|
88
|
-
type: "typed-number",
|
|
89
|
-
numberType: node.numberType,
|
|
90
|
-
});
|
|
91
|
-
this._defaults.set(node.id, node.default);
|
|
92
|
-
continue;
|
|
93
|
-
}
|
|
94
|
-
if (node.type == "number-array") {
|
|
95
|
-
tags.registerProperty({
|
|
96
|
-
id: node.id,
|
|
97
|
-
type: "typed-number-array",
|
|
98
|
-
numberType: node.numberType,
|
|
99
|
-
length: node.length,
|
|
100
|
-
});
|
|
101
|
-
continue;
|
|
102
|
-
}
|
|
103
|
-
if (node.type == "boolean") {
|
|
104
|
-
tags.registerProperty({
|
|
105
|
-
id: node.id,
|
|
106
|
-
type: "boolean",
|
|
107
|
-
});
|
|
108
|
-
this._defaults.set(node.id, node.default ? 1 : 0);
|
|
109
|
-
}
|
|
110
|
-
if (node.type == "string-map") {
|
|
111
|
-
tags.registerProperty({
|
|
112
|
-
id: node.id,
|
|
113
|
-
type: "typed-number",
|
|
114
|
-
numberType: BinaryNumberTypes.Uint16,
|
|
115
|
-
});
|
|
116
|
-
this._stringMaps.set(node.id, {
|
|
117
|
-
count: 0,
|
|
118
|
-
found: {},
|
|
119
|
-
map: [],
|
|
120
|
-
allowedComms: node.allowedComms,
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
if (node.type == "object-map") {
|
|
124
|
-
tags.registerProperty({
|
|
125
|
-
id: node.id,
|
|
126
|
-
type: "typed-number",
|
|
127
|
-
numberType: BinaryNumberTypes.Uint16,
|
|
128
|
-
});
|
|
129
|
-
this._objectMaps.set(node.id, {
|
|
130
|
-
count: 0,
|
|
131
|
-
found: {},
|
|
132
|
-
map: [],
|
|
133
|
-
allowedComms: node.allowedComms,
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
tags.init({
|
|
138
|
-
indexBufferMode: "shared",
|
|
139
|
-
numberOfIndexes: totalTagIndexes,
|
|
140
|
-
});
|
|
141
|
-
return tags;
|
|
142
|
-
}
|
|
143
|
-
getMaps() {
|
|
144
|
-
const objectMaps = {};
|
|
145
|
-
const stringMaps = {};
|
|
146
|
-
for (const [key, value] of this._stringMaps) {
|
|
147
|
-
stringMaps[key] = value.map;
|
|
148
|
-
}
|
|
149
|
-
for (const [key, value] of this._objectMaps) {
|
|
150
|
-
objectMaps[key] = value.map;
|
|
151
|
-
}
|
|
152
|
-
return {
|
|
153
|
-
objectMaps,
|
|
154
|
-
stringMaps,
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { BinaryNumberTypes } from "@amodx/binary/";
|
|
2
|
-
type TagBuilderNodeBase = {
|
|
3
|
-
id: string;
|
|
4
|
-
};
|
|
5
|
-
type TagBuilderNumberNode = {
|
|
6
|
-
type: "number";
|
|
7
|
-
numberType: BinaryNumberTypes;
|
|
8
|
-
default: number;
|
|
9
|
-
} & TagBuilderNodeBase;
|
|
10
|
-
type TagBuilderNumberArrayNode = {
|
|
11
|
-
type: "number-array";
|
|
12
|
-
numberType: BinaryNumberTypes;
|
|
13
|
-
length: number;
|
|
14
|
-
} & TagBuilderNodeBase;
|
|
15
|
-
type TagBuilderStringMapNode = {
|
|
16
|
-
type: "string-map";
|
|
17
|
-
allowedComms: string[];
|
|
18
|
-
default?: string;
|
|
19
|
-
} & TagBuilderNodeBase;
|
|
20
|
-
type TagBuilderObjectMapNode = {
|
|
21
|
-
type: "object-map";
|
|
22
|
-
allowedComms: string[];
|
|
23
|
-
default?: any;
|
|
24
|
-
} & TagBuilderNodeBase;
|
|
25
|
-
type TagBuilderBooleanNode = {
|
|
26
|
-
type: "boolean";
|
|
27
|
-
default: boolean;
|
|
28
|
-
} & TagBuilderNodeBase;
|
|
29
|
-
export type TagBuilderNodes = TagBuilderNumberNode | TagBuilderNumberArrayNode | TagBuilderStringMapNode | TagBuilderBooleanNode | TagBuilderObjectMapNode;
|
|
30
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { SubstanceStruct } from "../../Voxels/Structs/SubstanceStruct.js";
|
|
2
|
-
export declare class SubstanceDataTool {
|
|
3
|
-
static tags: typeof SubstanceStruct;
|
|
4
|
-
substanceTagIndex: number;
|
|
5
|
-
setSubstanceFromString(substance: string): this;
|
|
6
|
-
setSubstance(substance: number): this;
|
|
7
|
-
getSubstanceStringId(): string;
|
|
8
|
-
isSolid(): boolean;
|
|
9
|
-
isLiquid(): boolean;
|
|
10
|
-
isWindAffected(): boolean;
|
|
11
|
-
getParent(): string;
|
|
12
|
-
getFlowRate(): number;
|
|
13
|
-
}
|