@divinevoxel/vlox 0.0.6 → 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/Render/DivineVoxelEngineRender.d.ts +5 -5
- package/Contexts/World/DivineVoxelEngineWorld.d.ts +5 -5
- package/Mesher/Functions/MeshSection.js +5 -2
- package/Mesher/Functions/MeshVoxel.js +3 -3
- package/Mesher/Geomtry/VoxelMesh.d.ts +1 -2
- package/Mesher/Geomtry/VoxelMesh.js +2 -5
- package/Mesher/Models/Common/BoxGeometryNode.js +2 -1
- package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.js +4 -1
- package/Mesher/Models/Nodes/VoxelGeometryConstructor.js +1 -1
- package/Mesher/Models/VoxelConstructor.d.ts +0 -2
- package/Mesher/Models/VoxelConstructor.js +6 -12
- package/Mesher/Models/VoxelGeometryLookUp.js +18 -18
- package/Mesher/Tools/VoxelMesherDataTool.d.ts +1 -0
- package/Mesher/Tools/VoxelMesherDataTool.js +5 -0
- package/Renderer/InitTasks.js +4 -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/Propagation/Explosion/ExplosionManager.js +1 -1
- package/Tasks/Propagation/Flow/WorldFlow.js +4 -4
- package/Tasks/Propagation/Illumanation/RGBUpdate.js +2 -2
- package/Tasks/Propagation/Illumanation/WorldRGB.js +1 -1
- package/Tasks/Propagation/Illumanation/WorldSun.js +10 -1
- package/Tasks/Update/VoxelUpdate.js +21 -26
- 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 +7 -9
- 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/Cursor/SectorCursor.d.ts +1 -0
- package/World/Cursor/SectorCursor.js +7 -1
- package/World/Cursor/WorldVoxelCursor.d.ts +1 -5
- package/World/Cursor/WorldVoxelCursor.js +1 -5
- package/World/WorldSpaces.d.ts +1 -1
- package/World/WorldSpaces.js +8 -8
- package/package.json +1 -1
- package/Voxels/VoxelStateReader.d.ts +0 -12
- package/Voxels/VoxelStateReader.js +0 -30
|
@@ -19,14 +19,14 @@ export declare class DivineVoxelEngineRender {
|
|
|
19
19
|
settings: {
|
|
20
20
|
enviorment: "node" | "browser";
|
|
21
21
|
settings: EngineSettingsData;
|
|
22
|
+
readonly doSunPropagation: boolean;
|
|
23
|
+
readonly doRGBPropagation: boolean;
|
|
24
|
+
readonly doLight: boolean;
|
|
25
|
+
readonly doFlow: boolean;
|
|
26
|
+
readonly isClient: boolean;
|
|
22
27
|
getSettings(): EngineSettingsData;
|
|
23
28
|
syncSettings(data: EngineSettingsData): void;
|
|
24
29
|
getSettingsCopy(): any;
|
|
25
|
-
doSunPropagation(): boolean;
|
|
26
|
-
doRGBPropagation(): boolean;
|
|
27
|
-
doLight(): boolean;
|
|
28
|
-
doFlow(): boolean;
|
|
29
|
-
isClient(): boolean;
|
|
30
30
|
addEventListener<K extends "synced">(type: K, listener: EventListenerObject | ((event: CustomEvent<{
|
|
31
31
|
synced: {
|
|
32
32
|
settings: any;
|
|
@@ -11,14 +11,14 @@ export declare class DivineVoxelEngineWorld {
|
|
|
11
11
|
settings: {
|
|
12
12
|
enviorment: "node" | "browser";
|
|
13
13
|
settings: import("../../Settings/EngineSettings.types.js").EngineSettingsData;
|
|
14
|
+
readonly doSunPropagation: boolean;
|
|
15
|
+
readonly doRGBPropagation: boolean;
|
|
16
|
+
readonly doLight: boolean;
|
|
17
|
+
readonly doFlow: boolean;
|
|
18
|
+
readonly isClient: boolean;
|
|
14
19
|
getSettings(): import("../../Settings/EngineSettings.types.js").EngineSettingsData;
|
|
15
20
|
syncSettings(data: import("../../Settings/EngineSettings.types.js").EngineSettingsData): void;
|
|
16
21
|
getSettingsCopy(): any;
|
|
17
|
-
doSunPropagation(): boolean;
|
|
18
|
-
doRGBPropagation(): boolean;
|
|
19
|
-
doLight(): boolean;
|
|
20
|
-
doFlow(): boolean;
|
|
21
|
-
isClient(): boolean;
|
|
22
22
|
addEventListener<K extends "synced">(type: K, listener: EventListenerObject | ((event: CustomEvent<{
|
|
23
23
|
synced: {
|
|
24
24
|
settings: any;
|
|
@@ -68,11 +68,14 @@ export function MeshSection(location) {
|
|
|
68
68
|
const maxZ = WorldSpaces.section.bounds.z;
|
|
69
69
|
if (Math.abs(minY) == Infinity && Math.abs(maxY) == Infinity)
|
|
70
70
|
return null;
|
|
71
|
-
space.start(cx - padding.x, cy - padding.y, cz - padding.z);
|
|
71
|
+
space.start(cx - (padding.x - 1), cy - (padding.y - 1), cz - (padding.z - 1));
|
|
72
72
|
VoxelGeometryLookUp.start(space);
|
|
73
73
|
bvhTool.reset();
|
|
74
|
+
const effects = {};
|
|
74
75
|
for (let i = 0; i < RenderedMaterials.meshers.length; i++) {
|
|
75
|
-
RenderedMaterials.meshers[i]
|
|
76
|
+
const mesher = RenderedMaterials.meshers[i];
|
|
77
|
+
mesher.bvhTool = bvhTool;
|
|
78
|
+
mesher.effects = effects;
|
|
76
79
|
}
|
|
77
80
|
for (let y = minY; y <= maxY; y++) {
|
|
78
81
|
let foundVoxels = false;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { RenderedMaterials } from "../RenderedMaterials";
|
|
2
2
|
import { VoxelGeometryLookUp } from "../Models/VoxelGeometryLookUp.js";
|
|
3
3
|
import { TemplateCursor } from "../../Templates/Cursor/TemplateCursor.js";
|
|
4
|
-
import { VoxelCursor } from "../../Voxels/Cursor/VoxelCursor.js";
|
|
5
4
|
import { FullVoxelTemplate } from "../../Templates/FullVoxelTemplate.js";
|
|
6
5
|
import { CompactVoxelMesh } from "../Functions/CompactVoxelMesh.js";
|
|
7
6
|
import { VoxelModelConstructorRegister } from "../Models/VoxelModelConstructorRegister.js";
|
|
8
7
|
const templateCursor = new TemplateCursor();
|
|
9
|
-
const voxelCursor = new VoxelCursor();
|
|
10
8
|
templateCursor.setTemplate(new FullVoxelTemplate(FullVoxelTemplate.CreateNew([3, 3, 3], 0xf)));
|
|
11
9
|
const space = VoxelGeometryLookUp.createSpace(3, 3, 3);
|
|
12
10
|
export function MeshVoxel(rawVoxelData) {
|
|
@@ -25,14 +23,16 @@ export function MeshVoxel(rawVoxelData) {
|
|
|
25
23
|
}
|
|
26
24
|
mesher.bvhTool = null;
|
|
27
25
|
mesher.resetAll();
|
|
26
|
+
space.start(0, 0, 0);
|
|
28
27
|
VoxelGeometryLookUp.start(space);
|
|
28
|
+
mesher.effects = {};
|
|
29
29
|
mesher.origin.x = -0.5;
|
|
30
30
|
mesher.origin.y = -0.5;
|
|
31
31
|
mesher.origin.z = -0.5;
|
|
32
32
|
mesher.position.x = 1;
|
|
33
33
|
mesher.position.y = 1;
|
|
34
34
|
mesher.position.z = 1;
|
|
35
|
-
mesher.voxel =
|
|
35
|
+
mesher.voxel = voxel;
|
|
36
36
|
mesher.nVoxel = templateCursor;
|
|
37
37
|
constructor.process(mesher);
|
|
38
38
|
mesher.reset();
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { Vector3Like } from "@amodx/math";
|
|
2
2
|
import { VoxelVertexBuffer, VoxelIndiceBuffer } from "./Buffers";
|
|
3
3
|
export declare class VoxelMesh {
|
|
4
|
-
indicieIndex: number;
|
|
5
4
|
indicieCount: number;
|
|
6
5
|
vertexCount: number;
|
|
7
6
|
minBounds: Vector3Like;
|
|
8
7
|
maxBounds: Vector3Like;
|
|
9
8
|
readonly buffer: VoxelVertexBuffer;
|
|
10
9
|
readonly indices: VoxelIndiceBuffer;
|
|
11
|
-
addVerticies(
|
|
10
|
+
addVerticies(vertexCount: number, indicesCount: number): void;
|
|
12
11
|
clear(): void;
|
|
13
12
|
}
|
|
@@ -2,20 +2,17 @@ import { Vector3Like } from "@amodx/math";
|
|
|
2
2
|
import { VoxelVertexBuffer, VoxelIndiceBuffer } from "./Buffers";
|
|
3
3
|
import { VoxelMeshVertexStructCursor } from "../Tools/VoxelMeshVertexStructCursor";
|
|
4
4
|
export class VoxelMesh {
|
|
5
|
-
indicieIndex = 0;
|
|
6
5
|
indicieCount = 0;
|
|
7
6
|
vertexCount = 0;
|
|
8
7
|
minBounds = Vector3Like.Create(Infinity, Infinity, Infinity);
|
|
9
8
|
maxBounds = Vector3Like.Create(-Infinity, -Infinity, -Infinity);
|
|
10
9
|
buffer = new VoxelVertexBuffer(VoxelMeshVertexStructCursor.VertexFloatSize, 1000);
|
|
11
10
|
indices = new VoxelIndiceBuffer(1000);
|
|
12
|
-
addVerticies(
|
|
13
|
-
this.vertexCount +=
|
|
11
|
+
addVerticies(vertexCount, indicesCount) {
|
|
12
|
+
this.vertexCount += vertexCount;
|
|
14
13
|
this.indicieCount += indicesCount;
|
|
15
14
|
}
|
|
16
15
|
clear() {
|
|
17
|
-
// this.buffer.length = 0;
|
|
18
|
-
//this.indices.length = 0;
|
|
19
16
|
this.indicieCount = 0;
|
|
20
17
|
this.vertexCount = 0;
|
|
21
18
|
this.minBounds.x = Infinity;
|
|
@@ -2,6 +2,7 @@ import { Vector3Like } from "@amodx/math";
|
|
|
2
2
|
import { VoxelFaces } from "../../../Math";
|
|
3
3
|
import { Quad } from "../../Geomtry/Primitives/Quad";
|
|
4
4
|
import { addQuadWeights } from "./Calc/CalcConstants";
|
|
5
|
+
import { TransformBox } from "../../../Models/Shared/Transform";
|
|
5
6
|
import { GetBounds } from "./BoundsFunctions";
|
|
6
7
|
export function GetBoxGeometryNodeData(points, transform) {
|
|
7
8
|
// const quads: Quad[] = [];
|
|
@@ -51,7 +52,7 @@ export function GetBoxGeometryNodeData(points, transform) {
|
|
|
51
52
|
[start.x, start.y, end.z],
|
|
52
53
|
[start.x, start.y, start.z],
|
|
53
54
|
]);
|
|
54
|
-
|
|
55
|
+
TransformBox(quads, transform);
|
|
55
56
|
const quadBounds = new Array(quads.length);
|
|
56
57
|
for (let i = 0; i < quads.length; i++) {
|
|
57
58
|
const positions = [];
|
|
@@ -33,6 +33,8 @@ export class BoxVoxelGometryNode extends GeoemtryNode {
|
|
|
33
33
|
const currentIndex = faceIndexes[positionIndex];
|
|
34
34
|
const p = VoxelRelativeCubeIndexPositionMap[currentIndex];
|
|
35
35
|
const hashed = VoxelGeometryLookUp.getHash(tool.nVoxel, tool.position.x + p[0], tool.position.y + p[1], tool.position.z + p[2]);
|
|
36
|
+
if (VoxelGeometryLookUp.space.foundHash[hashed] < 2)
|
|
37
|
+
continue;
|
|
36
38
|
const offsetBaseGometry = VoxelGeometryLookUp.space.getGeomtry(hashed);
|
|
37
39
|
const offsetConditonalGeometry = VoxelGeometryLookUp.space.getConditionalGeomtry(hashed);
|
|
38
40
|
if (offsetBaseGometry) {
|
|
@@ -83,7 +85,8 @@ export class BoxVoxelGometryNode extends GeoemtryNode {
|
|
|
83
85
|
const currentIndex = aoIndexes[positionIndex];
|
|
84
86
|
const p = VoxelRelativeCubeIndexPositionMap[currentIndex];
|
|
85
87
|
const hashed = VoxelGeometryLookUp.getHash(tool.nVoxel, tool.position.x + p[0], tool.position.y + p[1], tool.position.z + p[2]);
|
|
86
|
-
if (VoxelGeometryLookUp.space.
|
|
88
|
+
if (VoxelGeometryLookUp.space.foundHash[hashed] < 2 ||
|
|
89
|
+
VoxelGeometryLookUp.space.noCastAO[hashed] === 1)
|
|
87
90
|
continue;
|
|
88
91
|
const baseGeo = VoxelGeometryLookUp.space.getGeomtry(hashed);
|
|
89
92
|
const conditonalGeo = VoxelGeometryLookUp.space.getConditionalGeomtry(hashed);
|
|
@@ -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
43
|
const treeState = VoxelGeometryLookUp.space.stateCache[hashed];
|
|
50
44
|
const modState = VoxelGeometryLookUp.space.modCache[hashed];
|
|
51
|
-
if (treeState
|
|
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;
|
|
@@ -64,7 +58,7 @@ export class VoxelConstructor {
|
|
|
64
58
|
}
|
|
65
59
|
}
|
|
66
60
|
const conditonalTreeState = VoxelGeometryLookUp.space.conditonalStateCache[hashed];
|
|
67
|
-
if (conditonalTreeState
|
|
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++) {
|
|
@@ -25,9 +25,11 @@ export class VoxelGeometryLookUpSpace {
|
|
|
25
25
|
this.offset[1] = y;
|
|
26
26
|
this.offset[2] = z;
|
|
27
27
|
this.foundHash.fill(0);
|
|
28
|
-
this.
|
|
29
|
-
this.stateCache.fill(-1);
|
|
28
|
+
this.voxelHash.fill(0);
|
|
30
29
|
this.modCache.fill(-1);
|
|
30
|
+
this.stateCache.fill(-1);
|
|
31
|
+
this.conditonalStateCache.fill(-1);
|
|
32
|
+
this.noCastAO.fill(0);
|
|
31
33
|
}
|
|
32
34
|
getIndex(x, y, z) {
|
|
33
35
|
return GetYXZOrderArrayIndex(x - this.offset[0], y - this.offset[1], z - this.offset[2], this.bounds.x, this.bounds.y, this.bounds.z);
|
|
@@ -65,42 +67,40 @@ export class VoxelGeometryLookUp {
|
|
|
65
67
|
static getHash(dataCursor, x, y, z) {
|
|
66
68
|
if (!this.space)
|
|
67
69
|
throw new Error(`Voxel geomtry look up must have space set`);
|
|
68
|
-
const hashed = this.space
|
|
69
|
-
if (this.space.foundHash[hashed] == 0)
|
|
70
|
+
const hashed = this.space.getIndex(x, y, z);
|
|
71
|
+
if (this.space.foundHash[hashed] == 0) {
|
|
70
72
|
this.hashState(dataCursor, hashed, x, y, z);
|
|
73
|
+
}
|
|
71
74
|
return hashed;
|
|
72
75
|
}
|
|
73
76
|
static hashState(dataCursor, index, x, y, z) {
|
|
74
77
|
if (!this.space)
|
|
75
78
|
throw new Error(`Voxel geomtry look up must have space set`);
|
|
79
|
+
if (this.space.foundHash[index] == 1)
|
|
80
|
+
return -1;
|
|
76
81
|
if (this.space.foundHash[index] == 2)
|
|
77
82
|
return this.space.stateCache[index];
|
|
78
83
|
const voxel = dataCursor.getVoxel(x, y, z);
|
|
79
|
-
if (!voxel) {
|
|
80
|
-
this.space.foundHash[index] = 1;
|
|
81
|
-
return -1;
|
|
82
|
-
}
|
|
83
|
-
if (!voxel.isRenderable()) {
|
|
84
|
+
if (!voxel || !voxel.isRenderable()) {
|
|
84
85
|
this.space.foundHash[index] = 1;
|
|
85
86
|
return -1;
|
|
86
87
|
}
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
if (!voxelConstructor
|
|
88
|
+
const voxelId = voxel.getId();
|
|
89
|
+
const voxelConstructor = VoxelModelConstructorRegister.constructorsPaltte[voxelId];
|
|
90
|
+
if (!voxelConstructor) {
|
|
90
91
|
this.space.foundHash[index] = 1;
|
|
91
92
|
return -1;
|
|
92
93
|
}
|
|
94
|
+
this.space.voxelHash[index] = voxelId;
|
|
93
95
|
this.space.foundHash[index] = 2;
|
|
94
96
|
//no ao
|
|
95
97
|
this.space.noCastAO[index] = voxel.isLightSource() || voxel.noAO() ? 1 : 0;
|
|
96
98
|
//state
|
|
97
|
-
const
|
|
98
|
-
const state = voxelConstructor.shapeStateTree.getState(shapeState);
|
|
99
|
+
const state = voxelConstructor.shapeStateTree.getState(voxel.getState());
|
|
99
100
|
this.space.stateCache[index] = state;
|
|
100
101
|
//mod
|
|
101
|
-
const mod = voxel.getMod();
|
|
102
|
-
|
|
103
|
-
this.space.modCache[index] = modState;
|
|
102
|
+
const mod = voxelConstructor.modTree.getState(voxel.getMod());
|
|
103
|
+
this.space.modCache[index] = mod;
|
|
104
104
|
this.voxelCursor.copy(voxel).process();
|
|
105
105
|
voxelConstructor.schema.position.x = x;
|
|
106
106
|
voxelConstructor.schema.position.y = y;
|
|
@@ -109,6 +109,6 @@ export class VoxelGeometryLookUp {
|
|
|
109
109
|
voxelConstructor.schema.dataCursor = dataCursor;
|
|
110
110
|
const conditonalState = voxelConstructor.condtioanlShapeStateTree.getState();
|
|
111
111
|
this.space.conditonalStateCache[index] = conditonalState;
|
|
112
|
-
return
|
|
112
|
+
return 1;
|
|
113
113
|
}
|
|
114
114
|
}
|
package/Renderer/InitTasks.js
CHANGED
|
@@ -2,6 +2,7 @@ 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
8
|
Threads.registerTask("set-section", (data, origin) => {
|
|
@@ -15,7 +16,9 @@ export default function RendererTasks(threads) {
|
|
|
15
16
|
tranfers.push(mesh[2]);
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
+
if (!EngineSettings.settings.rendererSettings.cpuBound) {
|
|
20
|
+
origin.sendMessage(data, tranfers);
|
|
21
|
+
}
|
|
19
22
|
});
|
|
20
23
|
Threads.registerTask("remove-sector", (data) => {
|
|
21
24
|
MeshManager.removeSector(data);
|
|
@@ -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();
|
|
@@ -1,46 +1,64 @@
|
|
|
1
|
+
import { Vector3Like } from "@amodx/math";
|
|
2
|
+
export interface RenderSettingsData {
|
|
3
|
+
}
|
|
4
|
+
export declare class RenderSettingsData {
|
|
5
|
+
mode: "webgl" | "webgpu";
|
|
6
|
+
cpuBound: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface TextureSettings {
|
|
9
|
+
}
|
|
10
|
+
export declare class TextureSettings {
|
|
11
|
+
textureSize: number;
|
|
12
|
+
}
|
|
13
|
+
export interface UpdatingSettings {
|
|
14
|
+
}
|
|
15
|
+
export declare class UpdatingSettings {
|
|
16
|
+
autoRebuild: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface WorldSettings {
|
|
19
|
+
}
|
|
20
|
+
export declare class WorldSettings {
|
|
21
|
+
min: Vector3Like;
|
|
22
|
+
max: Vector3Like;
|
|
23
|
+
}
|
|
24
|
+
export interface SectorSettings {
|
|
25
|
+
}
|
|
26
|
+
export declare class SectorSettings {
|
|
27
|
+
power2Size: Vector3Like;
|
|
28
|
+
}
|
|
29
|
+
export interface SectionSettings {
|
|
30
|
+
}
|
|
31
|
+
export declare class SectionSettings {
|
|
32
|
+
power2Size: Vector3Like;
|
|
33
|
+
}
|
|
34
|
+
export interface VoxelSettings {
|
|
35
|
+
}
|
|
36
|
+
export declare class VoxelSettings {
|
|
37
|
+
doColors: boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface FlowSettings {
|
|
40
|
+
}
|
|
41
|
+
export declare class FlowSettings {
|
|
42
|
+
enable: boolean;
|
|
43
|
+
baseFlowLimit: number;
|
|
44
|
+
}
|
|
45
|
+
export interface LightingSettings {
|
|
46
|
+
}
|
|
47
|
+
export declare class LightingSettings {
|
|
48
|
+
doAO: boolean;
|
|
49
|
+
doSunLight: boolean;
|
|
50
|
+
doRGBLight: boolean;
|
|
51
|
+
autoRGBLight: boolean;
|
|
52
|
+
autoSunLight: boolean;
|
|
53
|
+
}
|
|
1
54
|
export declare class EngineSettingsData {
|
|
2
|
-
rendererSettings:
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
autoRebuild: boolean;
|
|
12
|
-
};
|
|
13
|
-
world: {
|
|
14
|
-
maxX: number;
|
|
15
|
-
minX: number;
|
|
16
|
-
maxZ: number;
|
|
17
|
-
minZ: number;
|
|
18
|
-
maxY: number;
|
|
19
|
-
minY: number;
|
|
20
|
-
};
|
|
21
|
-
sectors: {
|
|
22
|
-
sectorXPow2: number;
|
|
23
|
-
sectorYPow2: number;
|
|
24
|
-
sectorZPow2: number;
|
|
25
|
-
};
|
|
26
|
-
sections: {
|
|
27
|
-
autoHeightMap: boolean;
|
|
28
|
-
sectionXPow2: number;
|
|
29
|
-
sectionYPow2: number;
|
|
30
|
-
sectionZPow2: number;
|
|
31
|
-
};
|
|
32
|
-
voxels: {
|
|
33
|
-
doColors: boolean;
|
|
34
|
-
};
|
|
35
|
-
flow: {
|
|
36
|
-
enable: boolean;
|
|
37
|
-
baseFlowLimit: number;
|
|
38
|
-
};
|
|
39
|
-
lighting: {
|
|
40
|
-
doAO: boolean;
|
|
41
|
-
doSunLight: boolean;
|
|
42
|
-
doRGBLight: boolean;
|
|
43
|
-
autoRGBLight: boolean;
|
|
44
|
-
autoSunLight: boolean;
|
|
45
|
-
};
|
|
55
|
+
rendererSettings: RenderSettingsData;
|
|
56
|
+
textures: TextureSettings;
|
|
57
|
+
updating: UpdatingSettings;
|
|
58
|
+
world: WorldSettings;
|
|
59
|
+
sectors: SectorSettings;
|
|
60
|
+
sections: SectionSettings;
|
|
61
|
+
voxels: VoxelSettings;
|
|
62
|
+
flow: FlowSettings;
|
|
63
|
+
lighting: LightingSettings;
|
|
46
64
|
}
|
|
@@ -1,44 +1,46 @@
|
|
|
1
|
+
import { Vector3Like } from "@amodx/math";
|
|
2
|
+
export class RenderSettingsData {
|
|
3
|
+
mode = "webgl";
|
|
4
|
+
cpuBound = false;
|
|
5
|
+
}
|
|
6
|
+
export class TextureSettings {
|
|
7
|
+
textureSize = 16;
|
|
8
|
+
}
|
|
9
|
+
export class UpdatingSettings {
|
|
10
|
+
autoRebuild = true;
|
|
11
|
+
}
|
|
12
|
+
export class WorldSettings {
|
|
13
|
+
min = Vector3Like.Create(-Number.MAX_SAFE_INTEGER, 0, -Number.MAX_SAFE_INTEGER);
|
|
14
|
+
max = Vector3Like.Create(Number.MAX_SAFE_INTEGER, 256, Number.MAX_SAFE_INTEGER);
|
|
15
|
+
}
|
|
16
|
+
export class SectorSettings {
|
|
17
|
+
power2Size = Vector3Like.Create(4, 8, 4);
|
|
18
|
+
}
|
|
19
|
+
export class SectionSettings {
|
|
20
|
+
power2Size = Vector3Like.Create(4, 4, 4);
|
|
21
|
+
}
|
|
22
|
+
export class VoxelSettings {
|
|
23
|
+
doColors = true;
|
|
24
|
+
}
|
|
25
|
+
export class FlowSettings {
|
|
26
|
+
enable = true;
|
|
27
|
+
baseFlowLimit = 200;
|
|
28
|
+
}
|
|
29
|
+
export class LightingSettings {
|
|
30
|
+
doAO = true;
|
|
31
|
+
doSunLight = true;
|
|
32
|
+
doRGBLight = true;
|
|
33
|
+
autoRGBLight = true;
|
|
34
|
+
autoSunLight = true;
|
|
35
|
+
}
|
|
1
36
|
export class EngineSettingsData {
|
|
2
|
-
rendererSettings =
|
|
3
|
-
textures =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
world = {
|
|
12
|
-
maxX: Number.MAX_SAFE_INTEGER,
|
|
13
|
-
minX: -Number.MAX_SAFE_INTEGER,
|
|
14
|
-
maxZ: Number.MAX_SAFE_INTEGER,
|
|
15
|
-
minZ: -Number.MAX_SAFE_INTEGER,
|
|
16
|
-
maxY: 256,
|
|
17
|
-
minY: 0,
|
|
18
|
-
};
|
|
19
|
-
sectors = {
|
|
20
|
-
sectorXPow2: 4,
|
|
21
|
-
sectorYPow2: 8,
|
|
22
|
-
sectorZPow2: 4,
|
|
23
|
-
};
|
|
24
|
-
sections = {
|
|
25
|
-
autoHeightMap: true,
|
|
26
|
-
sectionXPow2: 4,
|
|
27
|
-
sectionYPow2: 4,
|
|
28
|
-
sectionZPow2: 4,
|
|
29
|
-
};
|
|
30
|
-
voxels = {
|
|
31
|
-
doColors: true,
|
|
32
|
-
};
|
|
33
|
-
flow = {
|
|
34
|
-
enable: true,
|
|
35
|
-
baseFlowLimit: 200,
|
|
36
|
-
};
|
|
37
|
-
lighting = {
|
|
38
|
-
doAO: true,
|
|
39
|
-
doSunLight: true,
|
|
40
|
-
doRGBLight: true,
|
|
41
|
-
autoRGBLight: true,
|
|
42
|
-
autoSunLight: true,
|
|
43
|
-
};
|
|
37
|
+
rendererSettings = new RenderSettingsData();
|
|
38
|
+
textures = new TextureSettings();
|
|
39
|
+
updating = new UpdatingSettings();
|
|
40
|
+
world = new WorldSettings();
|
|
41
|
+
sectors = new SectorSettings();
|
|
42
|
+
sections = new SectionSettings();
|
|
43
|
+
voxels = new VoxelSettings();
|
|
44
|
+
flow = new FlowSettings();
|
|
45
|
+
lighting = new LightingSettings();
|
|
44
46
|
}
|
package/Tasks/IWG/IWG.d.ts
CHANGED
|
@@ -8,6 +8,9 @@ interface IWGInitData {
|
|
|
8
8
|
threads: Thread | ThreadPool;
|
|
9
9
|
worldStorage?: WorldStorageInterface;
|
|
10
10
|
}
|
|
11
|
+
/**# Infinite World Generation IWG
|
|
12
|
+
* Object to handle the loading and generating the world around a created generator.
|
|
13
|
+
*/
|
|
11
14
|
export declare class IWG {
|
|
12
15
|
private static _cullGenerators;
|
|
13
16
|
static readonly _generators: Generator[];
|
package/Tasks/IWG/IWG.js
CHANGED
|
@@ -10,6 +10,9 @@ import { Vector3Like } from "@amodx/math";
|
|
|
10
10
|
import { InitalLoad } from "./Procedures/InitalLoad";
|
|
11
11
|
import SaveAllSectors from "./Procedures/SaveAllSectors";
|
|
12
12
|
let initalized = false;
|
|
13
|
+
/**# Infinite World Generation IWG
|
|
14
|
+
* Object to handle the loading and generating the world around a created generator.
|
|
15
|
+
*/
|
|
13
16
|
export class IWG {
|
|
14
17
|
static _cullGenerators = [];
|
|
15
18
|
static _generators = [];
|
|
@@ -50,13 +50,13 @@ function Flood(task, voxel) {
|
|
|
50
50
|
nState == 0) {
|
|
51
51
|
if (downAir && !downSameVoxel) {
|
|
52
52
|
nVoxel.setId(voxelId);
|
|
53
|
-
nVoxel.
|
|
53
|
+
nVoxel.updateVoxel(0);
|
|
54
54
|
nVoxel.setLevel(7);
|
|
55
55
|
nVoxel.setLevelState(1);
|
|
56
56
|
}
|
|
57
57
|
else if (!downSameVoxel) {
|
|
58
58
|
nVoxel.setId(voxelId);
|
|
59
|
-
nVoxel.
|
|
59
|
+
nVoxel.updateVoxel(0);
|
|
60
60
|
nVoxel.setLevel(level - 1);
|
|
61
61
|
nVoxel.setLevelState(0);
|
|
62
62
|
}
|
|
@@ -98,14 +98,14 @@ function Flood(task, voxel) {
|
|
|
98
98
|
task.rgb.remove.push(x, y - 1, z);
|
|
99
99
|
}
|
|
100
100
|
nVoxel.setId(voxelId);
|
|
101
|
-
nVoxel.
|
|
101
|
+
nVoxel.updateVoxel(0);
|
|
102
102
|
nVoxel.setLevel(7);
|
|
103
103
|
nVoxel.setLevelState(state);
|
|
104
104
|
queue.push(x, y - 1, z);
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
export function WorldFlow(task) {
|
|
108
|
-
if (!EngineSettings.doFlow
|
|
108
|
+
if (!EngineSettings.doFlow)
|
|
109
109
|
return false;
|
|
110
110
|
const sector = WorldRegister.sectors.get(task.origin[0], task.origin[1], task.origin[2], task.origin[3]);
|
|
111
111
|
if (!sector) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { $3dCardinalNeighbors } from "../../../Math/CardinalNeighbors";
|
|
2
|
-
import { getMinusOneForRGB, isGreaterOrEqualThanForRGBRemove, isLessThanForRGBAdd, isLessThanForRGBRemove,
|
|
2
|
+
import { getMinusOneForRGB, isGreaterOrEqualThanForRGBRemove, isLessThanForRGBAdd, isLessThanForRGBRemove, removeRGBLight, } from "./CommonFunctions";
|
|
3
3
|
//@todo change array to not use push and shift
|
|
4
4
|
export function RGBUpdate(tasks) {
|
|
5
5
|
const queue = tasks.rgb.update;
|
|
@@ -76,7 +76,7 @@ export function RGBRemove(tasks) {
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
tasks.bounds.update(x, y, z);
|
|
79
|
-
voxel.setLight(
|
|
79
|
+
voxel.setLight(removeRGBLight(sl));
|
|
80
80
|
}
|
|
81
81
|
removeMap.clear();
|
|
82
82
|
}
|
|
@@ -6,7 +6,7 @@ import { EngineSettings } from "../../../Settings/EngineSettings";
|
|
|
6
6
|
import { RGBUpdate } from "./RGBUpdate";
|
|
7
7
|
const sectionCursor = new SectionCursor();
|
|
8
8
|
export function WorldRGB(task) {
|
|
9
|
-
if (!EngineSettings.doLight
|
|
9
|
+
if (!EngineSettings.doLight)
|
|
10
10
|
return false;
|
|
11
11
|
const sector = WorldRegister.sectors.get(task.origin[0], task.origin[1], task.origin[2], task.origin[3]);
|
|
12
12
|
if (!sector) {
|
|
@@ -27,8 +27,10 @@ export function RunWorldSun(tasks) {
|
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
29
|
const minY = AmaxY - 1 < 0 ? 0 : AmaxY;
|
|
30
|
+
const section = sectorCursor.getSection(cx, minY, cz);
|
|
31
|
+
const sectionY = section.getPosition()[1] + WorldSpaces.section.bounds.y;
|
|
30
32
|
//fill
|
|
31
|
-
for (let iy = minY; iy <
|
|
33
|
+
for (let iy = minY; iy < sectionY; iy++) {
|
|
32
34
|
for (let ix = cx; ix < maxX; ix++) {
|
|
33
35
|
for (let iz = cz; iz < maxZ; iz++) {
|
|
34
36
|
const voxel = sectorCursor.getVoxel(ix, iy, iz);
|
|
@@ -41,6 +43,13 @@ export function RunWorldSun(tasks) {
|
|
|
41
43
|
}
|
|
42
44
|
}
|
|
43
45
|
}
|
|
46
|
+
for (let iy = sectionY; iy < maxY; iy += WorldSpaces.section.bounds.y) {
|
|
47
|
+
const section = sectorCursor.getSection(cx, iy, cz);
|
|
48
|
+
const length = section.light.length;
|
|
49
|
+
for (let i = 0; i < length; i++) {
|
|
50
|
+
section.light[i] = lightData.setS(0xf, section.light[i]);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
44
53
|
const maxAcculamteY = AmaxY == RmaxY ? RmaxY + 1 : RmaxY;
|
|
45
54
|
let index = queue.length;
|
|
46
55
|
//accumulate
|
|
@@ -9,8 +9,8 @@ import { FlowRemove } from "../Propagation/Flow/FlowRemove.js";
|
|
|
9
9
|
const tasks = new UpdateTask();
|
|
10
10
|
const substanceData = new SubstanceDataTool();
|
|
11
11
|
const updateLightTask = (tasks) => {
|
|
12
|
-
let doRGB = ES.doRGBPropagation
|
|
13
|
-
let doSun = ES.doSunPropagation
|
|
12
|
+
let doRGB = ES.doRGBPropagation;
|
|
13
|
+
let doSun = ES.doSunPropagation;
|
|
14
14
|
const [dimension, x, y, z] = tasks.origin;
|
|
15
15
|
tasks.nDataCursor.setFocalPoint(dimension, x, y, z);
|
|
16
16
|
for (const n of $3dCardinalNeighbors) {
|
|
@@ -39,7 +39,7 @@ export async function EreaseAndUpdate(location) {
|
|
|
39
39
|
if (!voxel)
|
|
40
40
|
return false;
|
|
41
41
|
substanceData.setSubstance(voxel.getSubstance());
|
|
42
|
-
if (!voxel.isAir() && ES.doFlow
|
|
42
|
+
if (!voxel.isAir() && ES.doFlow && voxel.isRenderable()) {
|
|
43
43
|
if (substanceData.isLiquid()) {
|
|
44
44
|
FlowRemove(tasks);
|
|
45
45
|
return tasks;
|
|
@@ -56,17 +56,17 @@ export async function EreaseAndUpdate(location) {
|
|
|
56
56
|
.setLevelState(0)
|
|
57
57
|
.setState(0)
|
|
58
58
|
.setMod(0)
|
|
59
|
-
.
|
|
60
|
-
if (ES.doLight
|
|
61
|
-
if (ES.doRGBPropagation
|
|
59
|
+
.updateVoxel(1);
|
|
60
|
+
if (ES.doLight) {
|
|
61
|
+
if (ES.doRGBPropagation && isLightSource) {
|
|
62
62
|
tasks.rgb.remove.push(x, y, z);
|
|
63
63
|
RGBRemove(tasks);
|
|
64
64
|
}
|
|
65
65
|
updateLightTask(tasks);
|
|
66
|
-
if (ES.doRGBPropagation
|
|
66
|
+
if (ES.doRGBPropagation) {
|
|
67
67
|
RGBUpdate(tasks);
|
|
68
68
|
}
|
|
69
|
-
if (ES.doSunPropagation
|
|
69
|
+
if (ES.doSunPropagation) {
|
|
70
70
|
SunUpdate(tasks);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
@@ -80,9 +80,9 @@ export async function PaintAndUpdate(data) {
|
|
|
80
80
|
return false;
|
|
81
81
|
const raw = data[1];
|
|
82
82
|
const isOpaque = voxel.isOpaque();
|
|
83
|
-
let doRGB = ES.doRGBPropagation
|
|
84
|
-
let doSun = ES.doSunPropagation
|
|
85
|
-
lighttest: if (ES.doLight
|
|
83
|
+
let doRGB = ES.doRGBPropagation;
|
|
84
|
+
let doSun = ES.doSunPropagation;
|
|
85
|
+
lighttest: if (ES.doLight) {
|
|
86
86
|
const light = voxel.getLight();
|
|
87
87
|
if (light <= 0)
|
|
88
88
|
break lighttest;
|
|
@@ -104,24 +104,19 @@ export async function PaintAndUpdate(data) {
|
|
|
104
104
|
if (id < 0)
|
|
105
105
|
return false;
|
|
106
106
|
voxel.setId(id);
|
|
107
|
-
voxel.
|
|
108
|
-
|
|
109
|
-
if (substance > -1 && !voxel.isAir()
|
|
110
|
-
? substanceData.setSubstance(voxel.getSubstance()).isLiquid()
|
|
111
|
-
: false) {
|
|
112
|
-
voxel.setLevel(7);
|
|
113
|
-
}
|
|
107
|
+
voxel.setLevel(raw[2]);
|
|
108
|
+
voxel.setState(raw[3]);
|
|
114
109
|
voxel.setMod(raw[4]);
|
|
115
110
|
if (raw[3] > 0 && voxel.canHaveSecondaryVoxel()) {
|
|
116
111
|
voxel.setSecondary(true);
|
|
117
|
-
voxel.setId(raw[
|
|
112
|
+
voxel.setId(raw[5]);
|
|
118
113
|
voxel.setSecondary(false);
|
|
119
114
|
}
|
|
120
115
|
if (voxel.isLightSource() && voxel.getLightSourceValue()) {
|
|
121
116
|
voxel.setLight(voxel.getLightSourceValue());
|
|
122
117
|
}
|
|
123
|
-
voxel.
|
|
124
|
-
if (ES.doLight
|
|
118
|
+
voxel.updateVoxel(0);
|
|
119
|
+
if (ES.doLight) {
|
|
125
120
|
updateLightTask(tasks);
|
|
126
121
|
if (doRGB) {
|
|
127
122
|
tasks.rgb.update.push(x, y, z);
|
|
@@ -132,7 +127,7 @@ export async function PaintAndUpdate(data) {
|
|
|
132
127
|
}
|
|
133
128
|
}
|
|
134
129
|
voxel = tasks.sDataCursor.getVoxel(x, y, z);
|
|
135
|
-
if (ES.doFlow
|
|
130
|
+
if (ES.doFlow) {
|
|
136
131
|
if (!voxel.isAir() &&
|
|
137
132
|
substanceData.setSubstance(voxel.getSubstance()).isLiquid()) {
|
|
138
133
|
FlowUpdate(tasks);
|
|
@@ -146,9 +141,9 @@ export async function VoxelUpdate(data) {
|
|
|
146
141
|
const voxel = tasks.sDataCursor.getVoxel(x, y, z);
|
|
147
142
|
if (!voxel)
|
|
148
143
|
return false;
|
|
149
|
-
let doRGB = ES.doRGBPropagation
|
|
150
|
-
let doSun = ES.doSunPropagation
|
|
151
|
-
if (ES.doLight
|
|
144
|
+
let doRGB = ES.doRGBPropagation;
|
|
145
|
+
let doSun = ES.doSunPropagation;
|
|
146
|
+
if (ES.doLight) {
|
|
152
147
|
updateLightTask(tasks);
|
|
153
148
|
if (doRGB) {
|
|
154
149
|
tasks.rgb.update.push(x, y, z);
|
|
@@ -159,7 +154,7 @@ export async function VoxelUpdate(data) {
|
|
|
159
154
|
SunUpdate(tasks);
|
|
160
155
|
}
|
|
161
156
|
}
|
|
162
|
-
if (ES.doFlow
|
|
157
|
+
if (ES.doFlow) {
|
|
163
158
|
if (substanceData.setSubstance(voxel.getSubstance()).isLiquid()) {
|
|
164
159
|
FlowUpdate(tasks);
|
|
165
160
|
}
|
|
@@ -4,7 +4,7 @@ export declare class TextureBuilder {
|
|
|
4
4
|
static finalImagWidth: number;
|
|
5
5
|
static finalImageHeight: number;
|
|
6
6
|
static _canvas: HTMLCanvasElement;
|
|
7
|
-
static defineTextureDimensions(textureSize: number
|
|
7
|
+
static defineTextureDimensions(textureSize: number): void;
|
|
8
8
|
static setUpImageCreation(): void;
|
|
9
9
|
static createMaterialTexture(name: string, images: Map<string, HTMLImageElement | string | false>, width?: number, height?: number): Promise<HTMLImageElement[]>;
|
|
10
10
|
static getRawData(imageSrc: string): Promise<Uint8ClampedArray>;
|
|
@@ -4,7 +4,7 @@ export class TextureBuilder {
|
|
|
4
4
|
static finalImagWidth = 16;
|
|
5
5
|
static finalImageHeight = 16;
|
|
6
6
|
static _canvas = document.createElement("canvas");
|
|
7
|
-
static defineTextureDimensions(textureSize
|
|
7
|
+
static defineTextureDimensions(textureSize) {
|
|
8
8
|
this.finalImagWidth = textureSize < 256 ? 256 : textureSize;
|
|
9
9
|
this.finalImageHeight = textureSize < 256 ? 256 : textureSize;
|
|
10
10
|
this._textureSize = textureSize;
|
|
@@ -17,7 +17,7 @@ export class TextureManager {
|
|
|
17
17
|
return this._ready;
|
|
18
18
|
}
|
|
19
19
|
static async init() {
|
|
20
|
-
TextureBuilder.defineTextureDimensions(EngineSettings.settings.textures.textureSize
|
|
20
|
+
TextureBuilder.defineTextureDimensions(EngineSettings.settings.textures.textureSize);
|
|
21
21
|
for (const [key, type] of this.textureTypes) {
|
|
22
22
|
await type.build();
|
|
23
23
|
}
|
package/Tools/Brush/Brush.d.ts
CHANGED
package/Tools/Brush/Brush.js
CHANGED
|
@@ -102,6 +102,7 @@ export class BrushTool {
|
|
|
102
102
|
this.y = 0;
|
|
103
103
|
this.z = 0;
|
|
104
104
|
}
|
|
105
|
+
_debug = false;
|
|
105
106
|
_paint() {
|
|
106
107
|
if (!this.dataCursor.inBounds(this.x, this.y, this.z))
|
|
107
108
|
return false;
|
|
@@ -112,7 +113,10 @@ export class BrushTool {
|
|
|
112
113
|
if (id < 0)
|
|
113
114
|
return false;
|
|
114
115
|
voxel.setId(id);
|
|
115
|
-
|
|
116
|
+
if (this._debug) {
|
|
117
|
+
console.warn(this.x, this.y, this.z, this.data.state);
|
|
118
|
+
}
|
|
119
|
+
voxel.setState(this.data.state);
|
|
116
120
|
voxel.setLevel(this.data.level);
|
|
117
121
|
voxel.setMod(this.data.mod);
|
|
118
122
|
if (this.data.secondaryVoxelId) {
|
|
@@ -126,19 +130,13 @@ export class BrushTool {
|
|
|
126
130
|
if (voxel.isLightSource() && voxel.getLightSourceValue()) {
|
|
127
131
|
voxel.setLight(voxel.getLightSourceValue());
|
|
128
132
|
}
|
|
129
|
-
|
|
130
|
-
DataHooks.paint.onRichVoxelPaint.notify([
|
|
131
|
-
this.voxelCursor.getStringId(),
|
|
132
|
-
[this.dimenion, x, y, z],
|
|
133
|
-
]);
|
|
134
|
-
} */
|
|
135
|
-
voxel.updateHeightMap(0);
|
|
133
|
+
voxel.updateVoxel(0);
|
|
136
134
|
}
|
|
137
135
|
_erase() {
|
|
138
136
|
const voxel = this.dataCursor.getVoxel(this.x, this.y, this.z);
|
|
139
137
|
if (!voxel)
|
|
140
138
|
return;
|
|
141
|
-
voxel.copyRaw(air).
|
|
139
|
+
voxel.copyRaw(air).updateVoxel(1);
|
|
142
140
|
}
|
|
143
141
|
paint() {
|
|
144
142
|
this._paint();
|
|
@@ -19,6 +19,11 @@ export declare abstract class VoxelCursorInterface {
|
|
|
19
19
|
abstract state: WritableArrayLike<number>;
|
|
20
20
|
abstract secondary: WritableArrayLike<number>;
|
|
21
21
|
abstract mod: WritableArrayLike<number>;
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* @param mode 0 for add 1 for remove
|
|
25
|
+
*/
|
|
26
|
+
abstract updateVoxel(mode: 0 | 1): void;
|
|
22
27
|
_lightData: VoxelLightData;
|
|
23
28
|
_substanceData: SubstanceDataTool;
|
|
24
29
|
process(): void;
|
|
@@ -2,7 +2,7 @@ import { VoxelStructIds } from "../Types/Voxel.types";
|
|
|
2
2
|
import { VoxelLightData } from "./VoxelLightData";
|
|
3
3
|
import { MappedDataRegister } from "../../Data/Register/MappedDataRegister";
|
|
4
4
|
import { VoxelStruct } from "../Structs/VoxelStruct";
|
|
5
|
-
import {
|
|
5
|
+
import { VoxelLevelReader } from "../VoxelLevelReader";
|
|
6
6
|
import { VoxelTagStates } from "../State/VoxelTagStates";
|
|
7
7
|
import { VoxelPalette } from "../Palettes/VoxelPalette";
|
|
8
8
|
import { SubstancePalette } from "../Palettes/SubstancePalette";
|
|
@@ -84,17 +84,17 @@ export class VoxelCursorInterface {
|
|
|
84
84
|
return this;
|
|
85
85
|
}
|
|
86
86
|
getLevel() {
|
|
87
|
-
return
|
|
87
|
+
return VoxelLevelReader.getLevel(this.level[this._index]);
|
|
88
88
|
}
|
|
89
89
|
setLevel(level) {
|
|
90
|
-
this.level[this._index] =
|
|
90
|
+
this.level[this._index] = VoxelLevelReader.setLevel(this.level[this._index], level);
|
|
91
91
|
return this;
|
|
92
92
|
}
|
|
93
93
|
getLevelState() {
|
|
94
|
-
return
|
|
94
|
+
return VoxelLevelReader.getLevelState(this.level[this._index]);
|
|
95
95
|
}
|
|
96
96
|
setLevelState(state) {
|
|
97
|
-
this.level[this._index] =
|
|
97
|
+
this.level[this._index] = VoxelLevelReader.setLevelState(this.level[this._index], state);
|
|
98
98
|
return this;
|
|
99
99
|
}
|
|
100
100
|
getState() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { VoxelCursorInterface } from "./VoxelCursor.interface";
|
|
2
2
|
import { VoxelPalette } from "../../Voxels/Palettes/VoxelPalette";
|
|
3
|
-
import {
|
|
3
|
+
import { VoxelLevelReader } from "../VoxelLevelReader";
|
|
4
4
|
export class VoxelCursor extends VoxelCursorInterface {
|
|
5
5
|
static VoxelDataToRaw(data, light = 0) {
|
|
6
6
|
const id = (data.id !== undefined && VoxelPalette.ids.getNumberId(data.id)) || 0;
|
|
@@ -9,9 +9,9 @@ export class VoxelCursor extends VoxelCursorInterface {
|
|
|
9
9
|
0;
|
|
10
10
|
let levleData = 0;
|
|
11
11
|
if (data.level !== undefined)
|
|
12
|
-
levleData =
|
|
12
|
+
levleData = VoxelLevelReader.setLevel(levleData, data.level);
|
|
13
13
|
if (data.levelState !== undefined)
|
|
14
|
-
levleData =
|
|
14
|
+
levleData = VoxelLevelReader.setLevelState(levleData, data.levelState);
|
|
15
15
|
return [id, light, levleData, data.state || 0, data.mod || 0, secondaryId];
|
|
16
16
|
}
|
|
17
17
|
ids = [0];
|
|
@@ -21,4 +21,6 @@ export class VoxelCursor extends VoxelCursorInterface {
|
|
|
21
21
|
secondary = [0];
|
|
22
22
|
mod = [0];
|
|
23
23
|
loadIn() { }
|
|
24
|
+
updateVoxel(mode) {
|
|
25
|
+
}
|
|
24
26
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**# Voxel Reader
|
|
2
|
+
* ---
|
|
3
|
+
* Used to decode voxel state data.
|
|
4
|
+
*/
|
|
5
|
+
export declare class VoxelLevelReader {
|
|
6
|
+
static getLevel(levelData: number): number;
|
|
7
|
+
static setLevel(levelData: number, level: number): number;
|
|
8
|
+
static getLevelState(levelData: number): number;
|
|
9
|
+
static setLevelState(levelData: number, levelState: number): number;
|
|
10
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const LEVEL_MASK = 0b0000_1111;
|
|
2
|
+
const LEVEL_STATE_MASK = 0b1111_0000;
|
|
3
|
+
/**# Voxel Reader
|
|
4
|
+
* ---
|
|
5
|
+
* Used to decode voxel state data.
|
|
6
|
+
*/
|
|
7
|
+
export class VoxelLevelReader {
|
|
8
|
+
static getLevel(levelData) {
|
|
9
|
+
return levelData & LEVEL_MASK;
|
|
10
|
+
}
|
|
11
|
+
static setLevel(levelData, level) {
|
|
12
|
+
return (levelData & ~LEVEL_MASK) | level;
|
|
13
|
+
}
|
|
14
|
+
static getLevelState(levelData) {
|
|
15
|
+
return (levelData & LEVEL_STATE_MASK) >> 4;
|
|
16
|
+
}
|
|
17
|
+
static setLevelState(levelData, levelState) {
|
|
18
|
+
return (levelData & ~LEVEL_STATE_MASK) | (levelState << 4);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -13,5 +13,6 @@ export declare class SectorCursor extends DataCursorInterface implements WorldSe
|
|
|
13
13
|
_sectorPosition: Vector3Like;
|
|
14
14
|
inBounds(x: number, y: number, z: number): boolean;
|
|
15
15
|
setSector(dimension: string, x: number, y: number, z: number): boolean;
|
|
16
|
+
getSection(x: number, y: number, z: number): Section | null;
|
|
16
17
|
getVoxel(x: number, y: number, z: number): WorldVoxelCursor | null;
|
|
17
18
|
}
|
|
@@ -38,7 +38,7 @@ export class SectorCursor extends DataCursorInterface {
|
|
|
38
38
|
this._sectorPosition.z = sector.position[2];
|
|
39
39
|
return true;
|
|
40
40
|
}
|
|
41
|
-
|
|
41
|
+
getSection(x, y, z) {
|
|
42
42
|
if (!this._current)
|
|
43
43
|
return null;
|
|
44
44
|
const section = this._current.sections[WorldSpaces.section.getIndex(x, y, z)];
|
|
@@ -48,6 +48,12 @@ export class SectorCursor extends DataCursorInterface {
|
|
|
48
48
|
this._section = null;
|
|
49
49
|
return null;
|
|
50
50
|
}
|
|
51
|
+
return section;
|
|
52
|
+
}
|
|
53
|
+
getVoxel(x, y, z) {
|
|
54
|
+
if (!this._current)
|
|
55
|
+
return null;
|
|
56
|
+
const section = this.getSection(x, y, z);
|
|
51
57
|
this._section = section;
|
|
52
58
|
this._voxelIndex = WorldSpaces.voxel.getIndex(x, y, z);
|
|
53
59
|
WorldSpaces.voxel.getPosition(x, y, z, this._voxelPosition);
|
|
@@ -14,10 +14,6 @@ export declare class WorldVoxelCursor extends VoxelCursorInterface {
|
|
|
14
14
|
/**
|
|
15
15
|
*
|
|
16
16
|
* @param mode 0 for add 1 for remove
|
|
17
|
-
* @param x
|
|
18
|
-
* @param y
|
|
19
|
-
* @param z
|
|
20
|
-
* @returns
|
|
21
17
|
*/
|
|
22
|
-
|
|
18
|
+
updateVoxel(mode: 0 | 1): boolean;
|
|
23
19
|
}
|
|
@@ -36,12 +36,8 @@ export class WorldVoxelCursor extends VoxelCursorInterface {
|
|
|
36
36
|
/**
|
|
37
37
|
*
|
|
38
38
|
* @param mode 0 for add 1 for remove
|
|
39
|
-
* @param x
|
|
40
|
-
* @param y
|
|
41
|
-
* @param z
|
|
42
|
-
* @returns
|
|
43
39
|
*/
|
|
44
|
-
|
|
40
|
+
updateVoxel(mode) {
|
|
45
41
|
Section.StateStruct.setData(this._section.sectionState);
|
|
46
42
|
const voxelPos = this.dataCursor._voxelPosition;
|
|
47
43
|
if (mode == 0) {
|
package/World/WorldSpaces.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ declare class WorldBounds {
|
|
|
8
8
|
MinY: number;
|
|
9
9
|
MaxY: number;
|
|
10
10
|
};
|
|
11
|
-
static setWorldBounds(minX: number,
|
|
11
|
+
static setWorldBounds(minX: number, minY: number, minZ: number, maxX: number, maxY: number, maxZ: number): void;
|
|
12
12
|
static inBounds(x: number, y: number, z: number): boolean;
|
|
13
13
|
static getWorldWidth(): number;
|
|
14
14
|
static getWorldDepth(): number;
|
package/World/WorldSpaces.js
CHANGED
|
@@ -13,7 +13,7 @@ class WorldBounds {
|
|
|
13
13
|
MinY: 0,
|
|
14
14
|
MaxY: 256,
|
|
15
15
|
};
|
|
16
|
-
static setWorldBounds(minX,
|
|
16
|
+
static setWorldBounds(minX, minY, minZ, maxX, maxY, maxZ) {
|
|
17
17
|
this.bounds.MinX = minX;
|
|
18
18
|
this.bounds.MaxX = maxX;
|
|
19
19
|
this.bounds.MinX = minZ;
|
|
@@ -125,16 +125,16 @@ export class WorldSpaces {
|
|
|
125
125
|
}
|
|
126
126
|
EngineSettings.addEventListener("synced", (event) => {
|
|
127
127
|
const { settings } = event.detail.settings;
|
|
128
|
-
WorldBounds.setWorldBounds(settings.world.
|
|
129
|
-
SectorSpace.power2Axes.x = settings.sectors.
|
|
130
|
-
SectorSpace.power2Axes.y = settings.sectors.
|
|
131
|
-
SectorSpace.power2Axes.z = settings.sectors.
|
|
128
|
+
WorldBounds.setWorldBounds(settings.world.min.x, settings.world.min.y, settings.world.min.z, settings.world.max.x, settings.world.max.y, settings.world.max.z);
|
|
129
|
+
SectorSpace.power2Axes.x = settings.sectors.power2Size.x;
|
|
130
|
+
SectorSpace.power2Axes.y = settings.sectors.power2Size.y;
|
|
131
|
+
SectorSpace.power2Axes.z = settings.sectors.power2Size.z;
|
|
132
132
|
SectorSpace.bounds.x = 1 << SectorSpace.power2Axes.x;
|
|
133
133
|
SectorSpace.bounds.y = 1 << SectorSpace.power2Axes.y;
|
|
134
134
|
SectorSpace.bounds.z = 1 << SectorSpace.power2Axes.z;
|
|
135
|
-
SectionSpace.power2Axes.x = settings.sections.
|
|
136
|
-
SectionSpace.power2Axes.y = settings.sections.
|
|
137
|
-
SectionSpace.power2Axes.z = settings.sections.
|
|
135
|
+
SectionSpace.power2Axes.x = settings.sections.power2Size.x;
|
|
136
|
+
SectionSpace.power2Axes.y = settings.sections.power2Size.y;
|
|
137
|
+
SectionSpace.power2Axes.z = settings.sections.power2Size.z;
|
|
138
138
|
SectionSpace.bounds.x = 1 << SectionSpace.power2Axes.x;
|
|
139
139
|
SectionSpace.bounds.y = 1 << SectionSpace.power2Axes.y;
|
|
140
140
|
SectionSpace.bounds.z = 1 << SectionSpace.power2Axes.z;
|
package/package.json
CHANGED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**# Voxel Reader
|
|
2
|
-
* ---
|
|
3
|
-
* Used to decode voxel state data.
|
|
4
|
-
*/
|
|
5
|
-
export declare class VoxelStateReader {
|
|
6
|
-
static getLevel(stateData: number): number;
|
|
7
|
-
static setLevel(stateData: number, level: number): number;
|
|
8
|
-
static getLevelState(stateData: number): number;
|
|
9
|
-
static setLevelState(stateData: number, levelState: number): number;
|
|
10
|
-
static getShapeState(voxelData: number): number;
|
|
11
|
-
static setShapeState(voxelData: number, shapeState: number): number;
|
|
12
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
var StateMasks;
|
|
2
|
-
(function (StateMasks) {
|
|
3
|
-
StateMasks[StateMasks["Level"] = 15] = "Level";
|
|
4
|
-
StateMasks[StateMasks["LevelState"] = 48] = "LevelState";
|
|
5
|
-
StateMasks[StateMasks["ShapeState"] = 65472] = "ShapeState";
|
|
6
|
-
})(StateMasks || (StateMasks = {}));
|
|
7
|
-
/**# Voxel Reader
|
|
8
|
-
* ---
|
|
9
|
-
* Used to decode voxel state data.
|
|
10
|
-
*/
|
|
11
|
-
export class VoxelStateReader {
|
|
12
|
-
static getLevel(stateData) {
|
|
13
|
-
return stateData & StateMasks.Level;
|
|
14
|
-
}
|
|
15
|
-
static setLevel(stateData, level) {
|
|
16
|
-
return (stateData & ~StateMasks.Level) | level;
|
|
17
|
-
}
|
|
18
|
-
static getLevelState(stateData) {
|
|
19
|
-
return (stateData & StateMasks.LevelState) >> 4;
|
|
20
|
-
}
|
|
21
|
-
static setLevelState(stateData, levelState) {
|
|
22
|
-
return (stateData & ~StateMasks.LevelState) | (levelState << 4);
|
|
23
|
-
}
|
|
24
|
-
static getShapeState(voxelData) {
|
|
25
|
-
return (voxelData & StateMasks.ShapeState) >> 6;
|
|
26
|
-
}
|
|
27
|
-
static setShapeState(voxelData, shapeState) {
|
|
28
|
-
return (voxelData & ~StateMasks.ShapeState) | (shapeState << 6);
|
|
29
|
-
}
|
|
30
|
-
}
|