@divinevoxel/vlox 0.0.5 → 0.0.7
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.d.ts +5 -5
- package/Contexts/Render/DivineVoxelEngineRender.js +1 -1
- package/Contexts/World/DivineVoxelEngineWorld.d.ts +5 -5
- package/Init/StartRenderer.js +5 -5
- package/Math/Indexing.js +6 -6
- package/Mesher/Functions/CompactVoxelMesh.js +40 -7
- package/Mesher/Functions/MeshSection.js +16 -9
- package/Mesher/Functions/MeshTexture.d.ts +1 -1
- package/Mesher/Functions/MeshVoxel.js +5 -4
- 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 +12 -0
- package/Mesher/Geomtry/VoxelMesh.js +25 -0
- package/Mesher/InitTask.js +1 -2
- package/Mesher/Models/Common/BoxGeometryNode.js +2 -1
- package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.js +10 -7
- package/Mesher/Models/Nodes/Ruled/QuadVoxelGeometryNode.js +7 -7
- package/Mesher/Models/Nodes/VoxelGeometryConstructor.js +1 -1
- package/Mesher/Models/VoxelConstructor.d.ts +0 -2
- package/Mesher/Models/VoxelConstructor.js +9 -15
- package/Mesher/Models/VoxelGeometryLookUp.d.ts +20 -11
- package/Mesher/Models/VoxelGeometryLookUp.js +84 -50
- package/Mesher/Tools/VoxelMeshBVHBuilder.js +20 -25
- package/Mesher/Tools/VoxelMeshVertexStructCursor.d.ts +3 -1
- package/Mesher/Tools/VoxelMesherDataTool.d.ts +3 -2
- package/Mesher/Tools/VoxelMesherDataTool.js +8 -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 +16 -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/Settings/EngineSettings.d.ts +5 -5
- package/Settings/EngineSettings.js +15 -15
- package/Settings/EngineSettings.types.d.ts +62 -44
- package/Settings/EngineSettings.types.js +44 -42
- package/Tasks/IWG/IWG.d.ts +3 -0
- package/Tasks/IWG/IWG.js +3 -0
- 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/Explosion/ExplosionManager.js +1 -1
- package/Tasks/Propagation/Flow/WorldFlow.js +6 -8
- package/Tasks/Propagation/Illumanation/RGBUpdate.js +2 -2
- package/Tasks/Propagation/Illumanation/WorldRGB.js +2 -3
- package/Tasks/Propagation/Illumanation/WorldSun.js +11 -5
- package/Tasks/Update/VoxelUpdate.js +21 -26
- package/Tasks/WorldGeneration/WorldGenRegister.js +5 -8
- package/Tasks/WorldGeneration/WorldGeneration.d.ts +0 -2
- package/Tasks/WorldGeneration/WorldGeneration.js +0 -2
- package/Templates/Cursor/TemplateVoxelCursor.d.ts +1 -0
- package/Templates/Cursor/TemplateVoxelCursor.js +1 -0
- package/Textures/TextureBuilder.d.ts +1 -1
- package/Textures/TextureBuilder.js +1 -1
- package/Textures/TextureManager.js +1 -1
- package/Tools/Brush/Brush.d.ts +1 -0
- package/Tools/Brush/Brush.js +8 -11
- package/Voxels/Cursor/VoxelCursor.d.ts +1 -0
- package/Voxels/Cursor/VoxelCursor.interface.d.ts +5 -0
- package/Voxels/Cursor/VoxelCursor.interface.js +5 -5
- package/Voxels/Cursor/VoxelCursor.js +5 -3
- package/Voxels/VoxelLevelReader.d.ts +10 -0
- package/Voxels/VoxelLevelReader.js +20 -0
- 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.d.ts +1 -0
- package/World/Cursor/SectorCursor.js +8 -3
- package/World/Cursor/WorldCursor.js +1 -2
- package/World/Cursor/WorldVoxelCursor.d.ts +1 -5
- package/World/Cursor/WorldVoxelCursor.js +1 -5
- 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/Voxels/VoxelStateReader.d.ts +0 -12
- package/Voxels/VoxelStateReader.js +0 -30
- package/World/WorldBounds.d.ts +0 -20
- package/World/WorldBounds.js +0 -53
|
@@ -21,8 +21,6 @@ export declare class VoxelConstructor {
|
|
|
21
21
|
shapeStateTree: StateTreeReader;
|
|
22
22
|
condtioanlShapeStateTree: CondtionalTreeReader;
|
|
23
23
|
constructor(id: string, data: CompiledVoxelModelData, voxleData: CompiledVoxelModelInputData);
|
|
24
|
-
getShapeStateTransaprentByteIndex(shapeState: number, geomtryId: number): number;
|
|
25
|
-
getCondtionalStateTransaprentByteIndex(shapeState: number, geomtryId: number): number;
|
|
26
24
|
isShapeStateFaceTransparent(modState: number, shapeState: number, geoId: number, faceIndex: number): boolean;
|
|
27
25
|
isCondtionalStateFaceTransparent(modState: number, shapeState: number, geoId: number, faceIndex: number): boolean;
|
|
28
26
|
process(tool: VoxelMesherDataTool): void;
|
|
@@ -25,30 +25,24 @@ export class VoxelConstructor {
|
|
|
25
25
|
this.baseInputMap = voxleData.baseGeometryInputMap;
|
|
26
26
|
this.conditonalInputMap = voxleData.condiotnalGeometryInputMap;
|
|
27
27
|
this.transparentIndex = new VoxelFaceTransparentResultsIndex(voxleData.transparentFaceIndex);
|
|
28
|
-
this.modSchema = new StateSchema(voxleData.modSchema);
|
|
29
|
-
this.modTree = new StateTreeReader(this.modSchema, 0, voxleData.modStateTree);
|
|
30
28
|
this.schema = new StateSchema(data.schema);
|
|
31
29
|
this.shapeStateTree = new StateTreeReader(this.schema, 0, data.shapeStateTree);
|
|
32
30
|
this.condtioanlShapeStateTree = new CondtionalTreeReader(this.schema, data.condiotnalStatements, data.condiotnalStateTree);
|
|
31
|
+
this.modSchema = new StateSchema(voxleData.modSchema);
|
|
32
|
+
this.modTree = new StateTreeReader(this.modSchema, 0, voxleData.modStateTree);
|
|
33
33
|
this.effects = new VoxelModelEffect(this);
|
|
34
34
|
}
|
|
35
|
-
getShapeStateTransaprentByteIndex(shapeState, geomtryId) {
|
|
36
|
-
return this.data.relativeGeometryByteIndexMap[this.data.shapeStateRelativeGeometryMap[shapeState][geomtryId]];
|
|
37
|
-
}
|
|
38
|
-
getCondtionalStateTransaprentByteIndex(shapeState, geomtryId) {
|
|
39
|
-
return this.data.relativeGeometryByteIndexMap[this.data.condiotnalShapeStateRelativeGeometryMap[shapeState][geomtryId]];
|
|
40
|
-
}
|
|
41
35
|
isShapeStateFaceTransparent(modState, shapeState, geoId, faceIndex) {
|
|
42
|
-
return (this.transparentIndex.getValue(modState, this.
|
|
36
|
+
return (this.transparentIndex.getValue(modState, this.data.relativeGeometryByteIndexMap[this.data.shapeStateRelativeGeometryMap[shapeState][geoId]], faceIndex) == 1);
|
|
43
37
|
}
|
|
44
38
|
isCondtionalStateFaceTransparent(modState, shapeState, geoId, faceIndex) {
|
|
45
|
-
return (this.transparentIndex.getValue(modState, this.
|
|
39
|
+
return (this.transparentIndex.getValue(modState, this.data.relativeGeometryByteIndexMap[this.data.condiotnalShapeStateRelativeGeometryMap[shapeState][geoId]], faceIndex) == 1);
|
|
46
40
|
}
|
|
47
41
|
process(tool) {
|
|
48
42
|
const hashed = VoxelGeometryLookUp.getHash(tool.nVoxel, tool.position.x, tool.position.y, tool.position.z);
|
|
49
|
-
const treeState = VoxelGeometryLookUp.stateCache[hashed];
|
|
50
|
-
const modState = VoxelGeometryLookUp.modCache[hashed];
|
|
51
|
-
if (treeState
|
|
43
|
+
const treeState = VoxelGeometryLookUp.space.stateCache[hashed];
|
|
44
|
+
const modState = VoxelGeometryLookUp.space.modCache[hashed];
|
|
45
|
+
if (treeState > -1) {
|
|
52
46
|
const geoLinks = this.data.shapeStateMap[treeState];
|
|
53
47
|
const geometries = this.data.shapeStateGeometryMap[treeState];
|
|
54
48
|
const geometriesLength = geoLinks.length;
|
|
@@ -63,8 +57,8 @@ export class VoxelConstructor {
|
|
|
63
57
|
}
|
|
64
58
|
}
|
|
65
59
|
}
|
|
66
|
-
const conditonalTreeState = VoxelGeometryLookUp.conditonalStateCache[hashed];
|
|
67
|
-
if (conditonalTreeState
|
|
60
|
+
const conditonalTreeState = VoxelGeometryLookUp.space.conditonalStateCache[hashed];
|
|
61
|
+
if (conditonalTreeState > -1) {
|
|
68
62
|
const condiotnalNodes = this.data.condiotnalShapeStateMap[conditonalTreeState];
|
|
69
63
|
const condiotnalNodesLength = condiotnalNodes.length;
|
|
70
64
|
for (let c = 0; c < condiotnalNodesLength; c++) {
|
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
import { DataCursorInterface } from "../../Data/Cursor/DataCursor.interface";
|
|
2
|
-
import {
|
|
3
|
-
import { Vec3Array } from "@amodx/math";
|
|
2
|
+
import { Vec3Array, Vector3Like } from "@amodx/math";
|
|
4
3
|
import { VoxelCursor } from "../../Voxels/Cursor/VoxelCursor";
|
|
4
|
+
export declare class VoxelGeometryLookUpSpace {
|
|
5
|
+
bounds: Vector3Like;
|
|
6
|
+
foundHash: Uint8Array;
|
|
7
|
+
voxelHash: Uint16Array;
|
|
8
|
+
modCache: Int32Array;
|
|
9
|
+
stateCache: Int32Array;
|
|
10
|
+
conditonalStateCache: Int32Array;
|
|
11
|
+
noCastAO: Uint8Array;
|
|
12
|
+
offset: Vec3Array;
|
|
13
|
+
constructor(bounds: Vector3Like);
|
|
14
|
+
start(x: number, y: number, z: number): void;
|
|
15
|
+
getIndex(x: number, y: number, z: number): number;
|
|
16
|
+
getConstructor(index: number): import("./VoxelConstructor").VoxelConstructor | null;
|
|
17
|
+
getGeomtry(index: number): false | number[];
|
|
18
|
+
getConditionalGeomtry(index: number): false | number[][];
|
|
19
|
+
}
|
|
5
20
|
export declare class VoxelGeometryLookUp {
|
|
6
|
-
static
|
|
7
|
-
static modCache: number[];
|
|
8
|
-
static stateCache: number[];
|
|
9
|
-
static conditonalStateCache: number[];
|
|
10
|
-
static geometryCache: number[][];
|
|
11
|
-
static conditionalGeometryCache: number[][][];
|
|
12
|
-
static noCastAO: boolean[];
|
|
13
|
-
static offset: Vec3Array;
|
|
21
|
+
static space: VoxelGeometryLookUpSpace | null;
|
|
14
22
|
static voxelCursor: VoxelCursor;
|
|
23
|
+
static createSpace(x: number, y: number, z: number): VoxelGeometryLookUpSpace;
|
|
15
24
|
static init(): void;
|
|
16
|
-
static start(
|
|
25
|
+
static start(space: VoxelGeometryLookUpSpace): void;
|
|
17
26
|
static isRulesless(geoId: number): boolean;
|
|
18
27
|
static stop(): void;
|
|
19
28
|
static getHash(dataCursor: DataCursorInterface, x: number, y: number, z: number): number;
|
|
@@ -1,67 +1,106 @@
|
|
|
1
1
|
import { VoxelModelConstructorRegister } from "./VoxelModelConstructorRegister";
|
|
2
|
-
import { Vector3Like } from "@amodx/math";
|
|
3
2
|
import { VoxelCursor } from "../../Voxels/Cursor/VoxelCursor";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
import { GetYXZOrderArrayIndex } from "../../Math/Indexing";
|
|
4
|
+
export class VoxelGeometryLookUpSpace {
|
|
5
|
+
bounds;
|
|
6
|
+
foundHash;
|
|
7
|
+
voxelHash;
|
|
8
|
+
modCache;
|
|
9
|
+
stateCache;
|
|
10
|
+
conditonalStateCache;
|
|
11
|
+
noCastAO;
|
|
12
|
+
offset = [0, 0, 0];
|
|
13
|
+
constructor(bounds) {
|
|
14
|
+
this.bounds = bounds;
|
|
15
|
+
const volume = bounds.x * bounds.y * bounds.z;
|
|
16
|
+
this.foundHash = new Uint8Array(volume);
|
|
17
|
+
this.voxelHash = new Uint16Array(volume);
|
|
18
|
+
this.modCache = new Int32Array(volume);
|
|
19
|
+
this.stateCache = new Int32Array(volume);
|
|
20
|
+
this.conditonalStateCache = new Int32Array(volume);
|
|
21
|
+
this.noCastAO = new Uint8Array(volume);
|
|
22
|
+
}
|
|
23
|
+
start(x, y, z) {
|
|
16
24
|
this.offset[0] = x;
|
|
17
25
|
this.offset[1] = y;
|
|
18
26
|
this.offset[2] = z;
|
|
27
|
+
this.foundHash.fill(0);
|
|
28
|
+
this.voxelHash.fill(0);
|
|
29
|
+
this.modCache.fill(-1);
|
|
30
|
+
this.stateCache.fill(-1);
|
|
31
|
+
this.conditonalStateCache.fill(-1);
|
|
32
|
+
this.noCastAO.fill(0);
|
|
33
|
+
}
|
|
34
|
+
getIndex(x, y, z) {
|
|
35
|
+
return GetYXZOrderArrayIndex(x - this.offset[0], y - this.offset[1], z - this.offset[2], this.bounds.x, this.bounds.y, this.bounds.z);
|
|
36
|
+
}
|
|
37
|
+
getConstructor(index) {
|
|
38
|
+
if (this.foundHash[index] !== 2)
|
|
39
|
+
return null;
|
|
40
|
+
return VoxelModelConstructorRegister.constructorsPaltte[this.voxelHash[index]];
|
|
41
|
+
}
|
|
42
|
+
getGeomtry(index) {
|
|
43
|
+
if (this.foundHash[index] !== 2)
|
|
44
|
+
return false;
|
|
45
|
+
return VoxelModelConstructorRegister.constructorsPaltte[this.voxelHash[index]].data.shapeStateGeometryMap[this.stateCache[index]];
|
|
46
|
+
}
|
|
47
|
+
getConditionalGeomtry(index) {
|
|
48
|
+
if (this.foundHash[index] !== 2)
|
|
49
|
+
return false;
|
|
50
|
+
return VoxelModelConstructorRegister.constructorsPaltte[this.voxelHash[index]].data.condiotnalShapeStateGeometryMap[this.conditonalStateCache[index]];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export class VoxelGeometryLookUp {
|
|
54
|
+
static space = null;
|
|
55
|
+
static voxelCursor = new VoxelCursor();
|
|
56
|
+
static createSpace(x, y, z) {
|
|
57
|
+
return new VoxelGeometryLookUpSpace({ x, y, z });
|
|
58
|
+
}
|
|
59
|
+
static init() { }
|
|
60
|
+
static start(space) {
|
|
61
|
+
this.space = space;
|
|
19
62
|
}
|
|
20
63
|
static isRulesless(geoId) {
|
|
21
64
|
return VoxelModelConstructorRegister.rulesless[geoId] == true;
|
|
22
65
|
}
|
|
23
|
-
static stop() {
|
|
24
|
-
this.stateCache.length = 0;
|
|
25
|
-
this.voxelHash.length = 0;
|
|
26
|
-
this.modCache.length = 0;
|
|
27
|
-
this.geometryCache.length = 0;
|
|
28
|
-
this.conditionalGeometryCache.length = 0;
|
|
29
|
-
this.conditonalStateCache.length = 0;
|
|
30
|
-
this.noCastAO.length = 0;
|
|
31
|
-
}
|
|
66
|
+
static stop() { }
|
|
32
67
|
static getHash(dataCursor, x, y, z) {
|
|
33
|
-
|
|
34
|
-
|
|
68
|
+
if (!this.space)
|
|
69
|
+
throw new Error(`Voxel geomtry look up must have space set`);
|
|
70
|
+
const hashed = this.space.getIndex(x, y, z);
|
|
71
|
+
if (this.space.foundHash[hashed] == 0) {
|
|
35
72
|
this.hashState(dataCursor, hashed, x, y, z);
|
|
73
|
+
}
|
|
36
74
|
return hashed;
|
|
37
75
|
}
|
|
38
|
-
static hashState(dataCursor,
|
|
39
|
-
if (this.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (!voxel) {
|
|
43
|
-
this.stateCache[hashed] = -1;
|
|
76
|
+
static hashState(dataCursor, index, x, y, z) {
|
|
77
|
+
if (!this.space)
|
|
78
|
+
throw new Error(`Voxel geomtry look up must have space set`);
|
|
79
|
+
if (this.space.foundHash[index] == 1)
|
|
44
80
|
return -1;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
81
|
+
if (this.space.foundHash[index] == 2)
|
|
82
|
+
return this.space.stateCache[index];
|
|
83
|
+
const voxel = dataCursor.getVoxel(x, y, z);
|
|
84
|
+
if (!voxel || !voxel.isRenderable()) {
|
|
85
|
+
this.space.foundHash[index] = 1;
|
|
48
86
|
return -1;
|
|
49
87
|
}
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
88
|
+
const voxelId = voxel.getId();
|
|
89
|
+
const voxelConstructor = VoxelModelConstructorRegister.constructorsPaltte[voxelId];
|
|
90
|
+
if (!voxelConstructor) {
|
|
91
|
+
this.space.foundHash[index] = 1;
|
|
53
92
|
return -1;
|
|
54
93
|
}
|
|
94
|
+
this.space.voxelHash[index] = voxelId;
|
|
95
|
+
this.space.foundHash[index] = 2;
|
|
55
96
|
//no ao
|
|
56
|
-
this.noCastAO[
|
|
97
|
+
this.space.noCastAO[index] = voxel.isLightSource() || voxel.noAO() ? 1 : 0;
|
|
57
98
|
//state
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
this.stateCache[hashed] = state;
|
|
99
|
+
const state = voxelConstructor.shapeStateTree.getState(voxel.getState());
|
|
100
|
+
this.space.stateCache[index] = state;
|
|
61
101
|
//mod
|
|
62
|
-
const mod = voxel.getMod();
|
|
63
|
-
|
|
64
|
-
this.modCache[hashed] = modState;
|
|
102
|
+
const mod = voxelConstructor.modTree.getState(voxel.getMod());
|
|
103
|
+
this.space.modCache[index] = mod;
|
|
65
104
|
this.voxelCursor.copy(voxel).process();
|
|
66
105
|
voxelConstructor.schema.position.x = x;
|
|
67
106
|
voxelConstructor.schema.position.y = y;
|
|
@@ -69,12 +108,7 @@ export class VoxelGeometryLookUp {
|
|
|
69
108
|
voxelConstructor.schema.voxel = this.voxelCursor;
|
|
70
109
|
voxelConstructor.schema.dataCursor = dataCursor;
|
|
71
110
|
const conditonalState = voxelConstructor.condtioanlShapeStateTree.getState();
|
|
72
|
-
this.
|
|
73
|
-
|
|
74
|
-
this.geometryCache[hashed] =
|
|
75
|
-
voxelConstructor.data.shapeStateGeometryMap[state];
|
|
76
|
-
this.conditionalGeometryCache[hashed] =
|
|
77
|
-
voxelConstructor.data.condiotnalShapeStateGeometryMap[conditonalState];
|
|
78
|
-
return state;
|
|
111
|
+
this.space.conditonalStateCache[index] = conditonalState;
|
|
112
|
+
return 1;
|
|
79
113
|
}
|
|
80
114
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { WorldSpaces } from "../../World/WorldSpaces";
|
|
2
|
+
const MAX_FLOAT32 = new Float32Array([Infinity])[0];
|
|
2
3
|
/**
|
|
3
4
|
* A class to help with indexing a full flat binary tree defined by the number of levels it has.
|
|
4
5
|
*/
|
|
@@ -160,23 +161,29 @@ export class StructCursor {
|
|
|
160
161
|
const ix = this.trueIndex;
|
|
161
162
|
const iy = this.trueIndex + 1;
|
|
162
163
|
const iz = this.trueIndex + 2;
|
|
163
|
-
this.data[ix]
|
|
164
|
-
this.data[ix]
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
164
|
+
if (x < this.data[ix] || this.data[ix] == -MAX_FLOAT32) {
|
|
165
|
+
this.data[ix] = x;
|
|
166
|
+
}
|
|
167
|
+
if (y < this.data[iy] || this.data[iy] == -MAX_FLOAT32) {
|
|
168
|
+
this.data[iy] = y;
|
|
169
|
+
}
|
|
170
|
+
if (z < this.data[iz] || this.data[iz] == -MAX_FLOAT32) {
|
|
171
|
+
this.data[iz] = z;
|
|
172
|
+
}
|
|
169
173
|
}
|
|
170
174
|
updateMax(x, y, z) {
|
|
171
175
|
const ix = this.trueIndex + 4;
|
|
172
176
|
const iy = this.trueIndex + 5;
|
|
173
177
|
const iz = this.trueIndex + 6;
|
|
174
|
-
this.data[ix]
|
|
175
|
-
this.data[ix]
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
178
|
+
if (x > this.data[ix] || this.data[ix] == -MAX_FLOAT32) {
|
|
179
|
+
this.data[ix] = x;
|
|
180
|
+
}
|
|
181
|
+
if (y > this.data[iy] || this.data[iy] == -MAX_FLOAT32) {
|
|
182
|
+
this.data[iy] = y;
|
|
183
|
+
}
|
|
184
|
+
if (z > this.data[iz] || this.data[iz] == -MAX_FLOAT32) {
|
|
185
|
+
this.data[iz] = z;
|
|
186
|
+
}
|
|
180
187
|
}
|
|
181
188
|
toJSON() {
|
|
182
189
|
return {
|
|
@@ -194,7 +201,7 @@ export class VoxelMeshBVHBuilder {
|
|
|
194
201
|
structCursor = new StructCursor(this.tree);
|
|
195
202
|
indices = new Uint32Array(this.treeIndex.getLevelSize(12) * 2);
|
|
196
203
|
reset() {
|
|
197
|
-
this.tree.fill(-
|
|
204
|
+
this.tree.fill(-MAX_FLOAT32);
|
|
198
205
|
this.indices.fill(0);
|
|
199
206
|
}
|
|
200
207
|
updateVoxel(voxelX, voxelY, voxelZ, meshIndex, indicesStart, indicesEnd, minX, minY, minZ, maxX, maxY, maxZ) {
|
|
@@ -219,15 +226,3 @@ export class VoxelMeshBVHBuilder {
|
|
|
219
226
|
}
|
|
220
227
|
}
|
|
221
228
|
}
|
|
222
|
-
/*
|
|
223
|
-
console.warn(
|
|
224
|
-
[voxelX, voxelY, voxelZ],
|
|
225
|
-
"add gometry",
|
|
226
|
-
[minX, minY, minZ],
|
|
227
|
-
[maxX, maxY, maxZ],
|
|
228
|
-
[voxelX, voxelY, voxelZ],
|
|
229
|
-
[indicesStart, indicesEnd],
|
|
230
|
-
indicesEnd - indicesStart,
|
|
231
|
-
(indicesEnd - indicesStart) / 3
|
|
232
|
-
);
|
|
233
|
-
*/
|
|
@@ -39,7 +39,9 @@ export declare class VoxelMeshVertexStructCursor {
|
|
|
39
39
|
set colorB(value: number);
|
|
40
40
|
trueIndex: number;
|
|
41
41
|
_index: number;
|
|
42
|
-
data:
|
|
42
|
+
data: {
|
|
43
|
+
[index: number]: number;
|
|
44
|
+
};
|
|
43
45
|
get index(): number;
|
|
44
46
|
set index(index: number);
|
|
45
47
|
constructor(data?: Float32Array);
|
|
@@ -2,7 +2,7 @@ import { MesherDataTool } from "../Geomtry/Tools/MesherDataTools";
|
|
|
2
2
|
import { QuadScalarVertexData } from "../Geomtry/Primitives/QuadVertexData";
|
|
3
3
|
import { VoxelFaces } from "../../Math";
|
|
4
4
|
import { QuadVerticies } from "../Geomtry/Geometry.types";
|
|
5
|
-
import {
|
|
5
|
+
import { VoxelMesh } from "../Geomtry/VoxelMesh";
|
|
6
6
|
import { VoxelMeshBVHBuilder } from "./VoxelMeshBVHBuilder";
|
|
7
7
|
import { Vec3Array, Vector3Like } from "@amodx/math";
|
|
8
8
|
import { VoxelCursorInterface } from "../../Voxels/Cursor/VoxelCursor.interface.js";
|
|
@@ -26,7 +26,7 @@ export declare class VoxelMesherDataTool extends MesherDataTool {
|
|
|
26
26
|
position: Vector3Like;
|
|
27
27
|
/**The current local origin */
|
|
28
28
|
origin: Vector3Like;
|
|
29
|
-
mesh:
|
|
29
|
+
mesh: VoxelMesh;
|
|
30
30
|
bvhTool: VoxelMeshBVHBuilder | null;
|
|
31
31
|
vars: VoxelVars;
|
|
32
32
|
dataCalculated: Record<VoxelFaces, boolean>;
|
|
@@ -44,5 +44,6 @@ export declare class VoxelMesherDataTool extends MesherDataTool {
|
|
|
44
44
|
calculateFaceData(direction: VoxelFaces): true | undefined;
|
|
45
45
|
clearCalculatedData(): void;
|
|
46
46
|
reset(): void;
|
|
47
|
+
resetAll(): this;
|
|
47
48
|
}
|
|
48
49
|
export {};
|
|
@@ -5,7 +5,7 @@ import { QuadScalarVertexData } from "../Geomtry/Primitives/QuadVertexData";
|
|
|
5
5
|
import { VoxelFaces, VoxelFacesArray } from "../../Math";
|
|
6
6
|
import { QuadVerticies } from "../Geomtry/Geometry.types";
|
|
7
7
|
import { FaceDataCalc } from "../Models/Common/Calc/FaceDataCalc.js";
|
|
8
|
-
import {
|
|
8
|
+
import { VoxelMesh } from "../Geomtry/VoxelMesh";
|
|
9
9
|
import { Vector3Like } from "@amodx/math";
|
|
10
10
|
class VoxelVars {
|
|
11
11
|
faceFlipped = false;
|
|
@@ -29,7 +29,7 @@ export class VoxelMesherDataTool extends MesherDataTool {
|
|
|
29
29
|
position = Vector3Like.Create();
|
|
30
30
|
/**The current local origin */
|
|
31
31
|
origin = Vector3Like.Create();
|
|
32
|
-
mesh = new
|
|
32
|
+
mesh = new VoxelMesh();
|
|
33
33
|
bvhTool = null;
|
|
34
34
|
vars = new VoxelVars();
|
|
35
35
|
dataCalculated;
|
|
@@ -70,7 +70,7 @@ export class VoxelMesherDataTool extends MesherDataTool {
|
|
|
70
70
|
this.lightData[face][QuadVerticies.BottomLeft] = 0;
|
|
71
71
|
this.lightData[face][QuadVerticies.BottomRight] = 0;
|
|
72
72
|
}
|
|
73
|
-
this.startNewMesh(new
|
|
73
|
+
this.startNewMesh(new VoxelMesh());
|
|
74
74
|
}
|
|
75
75
|
bounds = {
|
|
76
76
|
min: [0, 0, 0],
|
|
@@ -112,4 +112,9 @@ export class VoxelMesherDataTool extends MesherDataTool {
|
|
|
112
112
|
reset() {
|
|
113
113
|
this.vars.reset();
|
|
114
114
|
}
|
|
115
|
+
resetAll() {
|
|
116
|
+
this.vars.reset();
|
|
117
|
+
this.mesh.clear();
|
|
118
|
+
return this;
|
|
119
|
+
}
|
|
115
120
|
}
|
|
@@ -3,4 +3,5 @@ import { CompactMeshData } from "../../Mesher/Types/Mesher.types";
|
|
|
3
3
|
import { SectionMesh } from "./SectionMesh";
|
|
4
4
|
export declare abstract class DVESectionMeshes {
|
|
5
5
|
abstract updateVertexData(section: SectionMesh, position: Vec3Array, data: CompactMeshData): SectionMesh;
|
|
6
|
+
abstract returnMesh(mesh: any): void;
|
|
6
7
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { DVESectionMeshInterface } from "./DVESectionMeshInterface";
|
|
2
1
|
import { VoxelEffect } from "../../Voxels/Effects/VoxelEffect";
|
|
3
2
|
import { SectorMesh } from "./SectorMesh";
|
|
4
3
|
import { Vec3Array } from "@amodx/math";
|
|
5
4
|
export declare class SectionMesh {
|
|
6
5
|
sector: SectorMesh;
|
|
7
6
|
index: number;
|
|
8
|
-
meshes: Map<string,
|
|
7
|
+
meshes: Map<string, any>;
|
|
9
8
|
effects: Map<string, VoxelEffect>;
|
|
10
9
|
constructor(sector: SectorMesh, index: number);
|
|
11
10
|
getPosition(): Vec3Array;
|
package/Renderer/InitTasks.js
CHANGED
|
@@ -2,9 +2,24 @@ import { Threads } from "@amodx/threads/";
|
|
|
2
2
|
import { MeshManager } from "./MeshManager";
|
|
3
3
|
import { MeshRegister } from "./MeshRegister";
|
|
4
4
|
import { TaskTool } from "../Tools/Tasks/TasksTool";
|
|
5
|
+
import { EngineSettings } from "../Settings/EngineSettings";
|
|
5
6
|
export default function RendererTasks(threads) {
|
|
6
7
|
const tasks = new TaskTool(threads);
|
|
7
|
-
Threads.registerTask("set-section", (data) =>
|
|
8
|
+
Threads.registerTask("set-section", (data, origin) => {
|
|
9
|
+
MeshManager.updateSection(data);
|
|
10
|
+
const tranfers = [];
|
|
11
|
+
for (const comp of data[1]) {
|
|
12
|
+
if (comp[0] !== 0)
|
|
13
|
+
continue;
|
|
14
|
+
for (const mesh of comp[1]) {
|
|
15
|
+
tranfers.push(mesh[1]);
|
|
16
|
+
tranfers.push(mesh[2]);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
if (!EngineSettings.settings.rendererSettings.cpuBound) {
|
|
20
|
+
origin.sendMessage(data, tranfers);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
8
23
|
Threads.registerTask("remove-sector", (data) => {
|
|
9
24
|
MeshManager.removeSector(data);
|
|
10
25
|
});
|
package/Renderer/MeshManager.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { type LocationData } from "../Math/index.js";
|
|
2
2
|
import { SectorMesh } from "./Classes/SectorMesh.js";
|
|
3
|
-
import { DVESectionMeshInterface } from "./Classes/DVESectionMeshInterface.js";
|
|
4
3
|
export type MeshRegisterDimensions = Map<string, Map<string, SectorMesh>>;
|
|
5
4
|
declare class Sectors {
|
|
6
5
|
static add(location: LocationData): SectorMesh;
|
|
@@ -10,11 +9,7 @@ declare class Sectors {
|
|
|
10
9
|
declare class Dimensions {
|
|
11
10
|
static add(id: string): Map<any, any>;
|
|
12
11
|
static get(id: string): Map<string, SectorMesh> | undefined;
|
|
13
|
-
static getAllMeshes(id: string): Generator<[
|
|
14
|
-
location: LocationData,
|
|
15
|
-
substance: string,
|
|
16
|
-
mesh: DVESectionMeshInterface
|
|
17
|
-
]>;
|
|
12
|
+
static getAllMeshes(id: string): Generator<[location: LocationData, substance: string, mesh: any]>;
|
|
18
13
|
static remove(id: string): boolean;
|
|
19
14
|
}
|
|
20
15
|
export declare class MeshRegister {
|
package/Renderer/index.d.ts
CHANGED
package/Renderer/index.js
CHANGED
|
@@ -12,14 +12,14 @@ type EngineSettingsEvents = {
|
|
|
12
12
|
declare class EngineSettingsClass extends TypedEventTarget<EngineSettingsEvents> {
|
|
13
13
|
enviorment: "node" | "browser";
|
|
14
14
|
settings: EngineSettingsData;
|
|
15
|
+
get doSunPropagation(): boolean;
|
|
16
|
+
get doRGBPropagation(): boolean;
|
|
17
|
+
get doLight(): boolean;
|
|
18
|
+
get doFlow(): boolean;
|
|
19
|
+
get isClient(): boolean;
|
|
15
20
|
getSettings(): EngineSettingsData;
|
|
16
21
|
syncSettings(data: EngineSettingsData): void;
|
|
17
22
|
getSettingsCopy(): any;
|
|
18
|
-
doSunPropagation(): boolean;
|
|
19
|
-
doRGBPropagation(): boolean;
|
|
20
|
-
doLight(): boolean;
|
|
21
|
-
doFlow(): boolean;
|
|
22
|
-
isClient(): boolean;
|
|
23
23
|
}
|
|
24
24
|
export declare const EngineSettings: EngineSettingsClass;
|
|
25
25
|
export {};
|
|
@@ -8,6 +8,21 @@ import { TypedEventTarget } from "../Util/TypedEventTarget.js";
|
|
|
8
8
|
class EngineSettingsClass extends TypedEventTarget {
|
|
9
9
|
enviorment = Environment.isNode() ? "node" : "browser";
|
|
10
10
|
settings = new EngineSettingsData();
|
|
11
|
+
get doSunPropagation() {
|
|
12
|
+
return this.settings.lighting.autoSunLight == true;
|
|
13
|
+
}
|
|
14
|
+
get doRGBPropagation() {
|
|
15
|
+
return this.settings.lighting.autoRGBLight == true;
|
|
16
|
+
}
|
|
17
|
+
get doLight() {
|
|
18
|
+
return this.doRGBPropagation || this.doSunPropagation;
|
|
19
|
+
}
|
|
20
|
+
get doFlow() {
|
|
21
|
+
return this.settings.flow.enable;
|
|
22
|
+
}
|
|
23
|
+
get isClient() {
|
|
24
|
+
return this.enviorment != "browser";
|
|
25
|
+
}
|
|
11
26
|
getSettings() {
|
|
12
27
|
return this.settings;
|
|
13
28
|
}
|
|
@@ -34,20 +49,5 @@ class EngineSettingsClass extends TypedEventTarget {
|
|
|
34
49
|
getSettingsCopy() {
|
|
35
50
|
return JSON.parse(JSON.stringify(this.settings));
|
|
36
51
|
}
|
|
37
|
-
doSunPropagation() {
|
|
38
|
-
return this.settings.lighting.autoSunLight == true;
|
|
39
|
-
}
|
|
40
|
-
doRGBPropagation() {
|
|
41
|
-
return this.settings.lighting.autoRGBLight == true;
|
|
42
|
-
}
|
|
43
|
-
doLight() {
|
|
44
|
-
return this.doRGBPropagation() || this.doSunPropagation();
|
|
45
|
-
}
|
|
46
|
-
doFlow() {
|
|
47
|
-
return this.settings.flow.enable;
|
|
48
|
-
}
|
|
49
|
-
isClient() {
|
|
50
|
-
return this.enviorment != "browser";
|
|
51
|
-
}
|
|
52
52
|
}
|
|
53
53
|
export const EngineSettings = new EngineSettingsClass();
|