@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
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { Vec3Array, Vec4Array
|
|
1
|
+
import { Vec3Array, Vec4Array } from "@amodx/math";
|
|
2
2
|
import { VoxelFaces } from "../../../../Math";
|
|
3
|
-
import { QuadScalarVertexData } from "../../../Geomtry/Primitives/QuadVertexData";
|
|
4
3
|
import { VoxelQuadGeometryNode } from "../../../../Models/VoxelModel.types";
|
|
5
4
|
import { Quad } from "../../../Geomtry/Primitives/Quad";
|
|
6
|
-
import { VoxelMesherDataTool } from "../../../../Mesher/Tools/VoxelMesherDataTool";
|
|
7
5
|
import { QuadVoxelGometryArgs } from "../../../../Models/Input/QuadVoxelGometryInputs";
|
|
8
6
|
import { GeoemtryNode } from "../GeometryNode";
|
|
9
7
|
import { VoxelLightData } from "../../../../Voxels/Cursor/VoxelLightData";
|
|
@@ -11,12 +9,10 @@ export declare class RulelessQuadVoxelGeometryNode extends GeoemtryNode<VoxelQua
|
|
|
11
9
|
quad: Quad;
|
|
12
10
|
quadBounds: [Vec3Array, Vec3Array];
|
|
13
11
|
vertexWeights: [Vec4Array, Vec4Array, Vec4Array, Vec4Array];
|
|
14
|
-
worldLight: QuadScalarVertexData;
|
|
15
|
-
worldAO: QuadScalarVertexData;
|
|
16
12
|
closestFace: VoxelFaces;
|
|
17
13
|
lightData: VoxelLightData;
|
|
18
14
|
init(): void;
|
|
19
15
|
determineShading(): void;
|
|
20
16
|
shouldFlip(): boolean;
|
|
21
|
-
add(
|
|
17
|
+
add(args: QuadVoxelGometryArgs): boolean;
|
|
22
18
|
}
|
|
@@ -4,7 +4,6 @@ import { getInterpolationValue, shouldCauseFlip, } from "../../Common/Calc/CalcC
|
|
|
4
4
|
import { QuadVoxelGometryInputs, } from "../../../../Models/Input/QuadVoxelGometryInputs";
|
|
5
5
|
import { GeoemtryNode } from "../GeometryNode";
|
|
6
6
|
import { GetQuadGeometryData } from "../../Common/QuadGeometryNode";
|
|
7
|
-
import { UpdateBounds } from "../../Common/BoundsFunctions";
|
|
8
7
|
import { VoxelLightData } from "../../../../Voxels/Cursor/VoxelLightData";
|
|
9
8
|
const ArgIndexes = QuadVoxelGometryInputs.ArgIndexes;
|
|
10
9
|
export class RulelessQuadVoxelGeometryNode extends GeoemtryNode {
|
|
@@ -14,8 +13,6 @@ export class RulelessQuadVoxelGeometryNode extends GeoemtryNode {
|
|
|
14
13
|
[0, 0, 0],
|
|
15
14
|
];
|
|
16
15
|
vertexWeights;
|
|
17
|
-
worldLight;
|
|
18
|
-
worldAO;
|
|
19
16
|
closestFace;
|
|
20
17
|
lightData = new VoxelLightData();
|
|
21
18
|
init() {
|
|
@@ -28,11 +25,11 @@ export class RulelessQuadVoxelGeometryNode extends GeoemtryNode {
|
|
|
28
25
|
this.closestFace = closestFace;
|
|
29
26
|
}
|
|
30
27
|
determineShading() {
|
|
31
|
-
const tool = this.
|
|
28
|
+
const tool = this.builder;
|
|
32
29
|
const lightData = tool.lightData[VoxelFaces.Up];
|
|
33
|
-
const noAO = this.
|
|
34
|
-
const worldLight = this.
|
|
35
|
-
const worldAO = this.
|
|
30
|
+
const noAO = this.builder.voxel.isLightSource() || this.builder.voxel.noAO();
|
|
31
|
+
const worldLight = this.builder.vars.light;
|
|
32
|
+
const worldAO = this.builder.vars.ao;
|
|
36
33
|
for (let v = 0; v < 4; v++) {
|
|
37
34
|
worldAO.vertices[v] = 0;
|
|
38
35
|
worldLight.vertices[v] = getInterpolationValue(lightData, this.vertexWeights[v]);
|
|
@@ -41,40 +38,40 @@ export class RulelessQuadVoxelGeometryNode extends GeoemtryNode {
|
|
|
41
38
|
}
|
|
42
39
|
}
|
|
43
40
|
shouldFlip() {
|
|
44
|
-
|
|
41
|
+
const worldLight = this.builder.vars.light;
|
|
42
|
+
const worldAO = this.builder.vars.ao;
|
|
43
|
+
if (shouldCauseFlip(worldAO.vertices[0], worldAO.vertices[1], worldAO.vertices[2], worldAO.vertices[3]))
|
|
45
44
|
return true;
|
|
46
|
-
return (shouldCauseFlip(this.lightData.getS(
|
|
47
|
-
shouldCauseFlip(this.lightData.sumRGB(
|
|
45
|
+
return (shouldCauseFlip(this.lightData.getS(worldLight.vertices[0]), this.lightData.getS(worldLight.vertices[1]), this.lightData.getS(worldLight.vertices[2]), this.lightData.getS(worldLight.vertices[3])) ||
|
|
46
|
+
shouldCauseFlip(this.lightData.sumRGB(worldLight.vertices[0]), this.lightData.sumRGB(worldLight.vertices[1]), this.lightData.sumRGB(worldLight.vertices[2]), this.lightData.sumRGB(worldLight.vertices[3])));
|
|
48
47
|
}
|
|
49
|
-
add(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
this.worldLight.setAll(0);
|
|
78
|
-
this.worldAO.setAll(0);
|
|
48
|
+
add(args) {
|
|
49
|
+
if (!args[ArgIndexes.Enabled])
|
|
50
|
+
return false;
|
|
51
|
+
const tool = this.builder;
|
|
52
|
+
tool.calculateFaceData(this.closestFace);
|
|
53
|
+
this.determineShading();
|
|
54
|
+
const quad = this.quad;
|
|
55
|
+
quad.flip = this.shouldFlip() || args[ArgIndexes.Fliped];
|
|
56
|
+
tool.vars.textureIndex = args[ArgIndexes.Texture];
|
|
57
|
+
quad.doubleSided = args[ArgIndexes.DoubleSided];
|
|
58
|
+
const uvs = args[ArgIndexes.UVs];
|
|
59
|
+
//1
|
|
60
|
+
quad.uvs.vertices[0].x = uvs[0][0];
|
|
61
|
+
quad.uvs.vertices[0].y = uvs[0][1];
|
|
62
|
+
//2
|
|
63
|
+
quad.uvs.vertices[1].x = uvs[1][0];
|
|
64
|
+
quad.uvs.vertices[1].y = uvs[1][1];
|
|
65
|
+
//3
|
|
66
|
+
quad.uvs.vertices[2].x = uvs[2][0];
|
|
67
|
+
quad.uvs.vertices[2].y = uvs[2][1];
|
|
68
|
+
//4
|
|
69
|
+
quad.uvs.vertices[3].x = uvs[3][0];
|
|
70
|
+
quad.uvs.vertices[3].y = uvs[3][1];
|
|
71
|
+
VoxelGeometryBuilder.addQuad(tool, tool.position, quad);
|
|
72
|
+
this.builder.updateBounds(this.quadBounds);
|
|
73
|
+
this.builder.vars.light.setAll(0);
|
|
74
|
+
this.builder.vars.ao.setAll(0);
|
|
75
|
+
return true;
|
|
79
76
|
}
|
|
80
77
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { TextureRegister } from "../../Textures/TextureRegister";
|
|
2
1
|
import { VoxelMesherDataTool } from "../../Mesher/Tools/VoxelMesherDataTool";
|
|
3
2
|
import { CompiledVoxelModelInputData, CompiledVoxelModelData } from "../../Voxels/Types/VoxelModelCompiledData.types";
|
|
4
3
|
import { StateSchema } from "../../Voxels/State/Schema/StateSchema";
|
|
@@ -8,6 +7,7 @@ import { VoxelModelEffect } from "./VoxelModelEffect";
|
|
|
8
7
|
import { CondtionalTreeReader } from "../../Voxels/State/CondiotnalTreeReader";
|
|
9
8
|
export declare class VoxelConstructor {
|
|
10
9
|
id: string;
|
|
10
|
+
builder: VoxelMesherDataTool;
|
|
11
11
|
data: CompiledVoxelModelData;
|
|
12
12
|
isModel: true;
|
|
13
13
|
geometries: number[][];
|
|
@@ -20,9 +20,8 @@ export declare class VoxelConstructor {
|
|
|
20
20
|
effects: VoxelModelEffect;
|
|
21
21
|
shapeStateTree: StateTreeReader;
|
|
22
22
|
condtioanlShapeStateTree: CondtionalTreeReader;
|
|
23
|
-
constructor(id: string, data: CompiledVoxelModelData, voxleData: CompiledVoxelModelInputData);
|
|
23
|
+
constructor(id: string, builder: VoxelMesherDataTool, data: CompiledVoxelModelData, voxleData: CompiledVoxelModelInputData);
|
|
24
24
|
isShapeStateFaceTransparent(modState: number, shapeState: number, geoId: number, faceIndex: number): boolean;
|
|
25
25
|
isCondtionalStateFaceTransparent(modState: number, shapeState: number, geoId: number, faceIndex: number): boolean;
|
|
26
|
-
process(
|
|
27
|
-
onTexturesRegistered(textureManager: typeof TextureRegister): void;
|
|
26
|
+
process(): boolean;
|
|
28
27
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { VoxelModelConstructorRegister } from "./VoxelModelConstructorRegister";
|
|
2
|
-
import { VoxelGeometryLookUp } from "./VoxelGeometryLookUp";
|
|
3
2
|
import { StateSchema } from "../../Voxels/State/Schema/StateSchema";
|
|
4
3
|
import { StateTreeReader } from "../../Voxels/State/StateTreeReader";
|
|
5
4
|
import { VoxelFaceTransparentResultsIndex } from "../../Models/Indexing/VoxelFaceTransparentResultsIndex";
|
|
@@ -7,6 +6,7 @@ import { VoxelModelEffect } from "./VoxelModelEffect";
|
|
|
7
6
|
import { CondtionalTreeReader } from "../../Voxels/State/CondiotnalTreeReader";
|
|
8
7
|
export class VoxelConstructor {
|
|
9
8
|
id;
|
|
9
|
+
builder;
|
|
10
10
|
data;
|
|
11
11
|
isModel = true;
|
|
12
12
|
geometries = [];
|
|
@@ -19,8 +19,9 @@ export class VoxelConstructor {
|
|
|
19
19
|
effects;
|
|
20
20
|
shapeStateTree;
|
|
21
21
|
condtioanlShapeStateTree;
|
|
22
|
-
constructor(id, data, voxleData) {
|
|
22
|
+
constructor(id, builder, data, voxleData) {
|
|
23
23
|
this.id = id;
|
|
24
|
+
this.builder = builder;
|
|
24
25
|
this.data = data;
|
|
25
26
|
this.baseInputMap = voxleData.baseGeometryInputMap;
|
|
26
27
|
this.conditonalInputMap = voxleData.condiotnalGeometryInputMap;
|
|
@@ -38,10 +39,12 @@ export class VoxelConstructor {
|
|
|
38
39
|
isCondtionalStateFaceTransparent(modState, shapeState, geoId, faceIndex) {
|
|
39
40
|
return (this.transparentIndex.getValue(modState, this.data.relativeGeometryByteIndexMap[this.data.condiotnalShapeStateRelativeGeometryMap[shapeState][geoId]], faceIndex) == 1);
|
|
40
41
|
}
|
|
41
|
-
process(
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
const
|
|
42
|
+
process() {
|
|
43
|
+
let added = false;
|
|
44
|
+
const builder = this.builder;
|
|
45
|
+
const hashed = builder.space.getHash(builder.nVoxel, builder.position.x, builder.position.y, builder.position.z);
|
|
46
|
+
const treeState = builder.space.stateCache[hashed];
|
|
47
|
+
const modState = builder.space.modCache[hashed];
|
|
45
48
|
if (treeState > -1) {
|
|
46
49
|
const geoLinks = this.data.shapeStateMap[treeState];
|
|
47
50
|
const geometries = this.data.shapeStateGeometryMap[treeState];
|
|
@@ -53,11 +56,15 @@ export class VoxelConstructor {
|
|
|
53
56
|
const geomtry = VoxelModelConstructorRegister.geometry[geometries[i]];
|
|
54
57
|
const nodesLength = geomtry.nodes.length;
|
|
55
58
|
for (let k = 0; k < nodesLength; k++) {
|
|
56
|
-
geomtry.nodes[k]
|
|
59
|
+
const geo = geomtry.nodes[k];
|
|
60
|
+
geo.builder = this.builder;
|
|
61
|
+
const addedGeo = geo.add(geoInputs[k]);
|
|
62
|
+
if (addedGeo)
|
|
63
|
+
added = true;
|
|
57
64
|
}
|
|
58
65
|
}
|
|
59
66
|
}
|
|
60
|
-
const conditonalTreeState =
|
|
67
|
+
const conditonalTreeState = builder.space.conditonalStateCache[hashed];
|
|
61
68
|
if (conditonalTreeState > -1) {
|
|
62
69
|
const condiotnalNodes = this.data.condiotnalShapeStateMap[conditonalTreeState];
|
|
63
70
|
const condiotnalNodesLength = condiotnalNodes.length;
|
|
@@ -71,13 +78,17 @@ export class VoxelConstructor {
|
|
|
71
78
|
const geomtry = VoxelModelConstructorRegister.geometry[this.data.geoLinkMap[nodeId]];
|
|
72
79
|
const nodesLength = geomtry.nodes.length;
|
|
73
80
|
for (let k = 0; k < nodesLength; k++) {
|
|
74
|
-
geomtry.nodes[k]
|
|
81
|
+
const geo = geomtry.nodes[k];
|
|
82
|
+
geo.builder = this.builder;
|
|
83
|
+
const addedGeo = geo.add(geoInputs[k]);
|
|
84
|
+
if (addedGeo)
|
|
85
|
+
added = true;
|
|
75
86
|
}
|
|
76
87
|
}
|
|
77
88
|
}
|
|
78
89
|
}
|
|
79
|
-
this.effects.addEffects(
|
|
80
|
-
|
|
90
|
+
this.effects.addEffects(builder.voxel.getState(), builder.origin, builder.effects);
|
|
91
|
+
builder.clearCalculatedData();
|
|
92
|
+
return added;
|
|
81
93
|
}
|
|
82
|
-
onTexturesRegistered(textureManager) { }
|
|
83
94
|
}
|
|
@@ -1,30 +1,24 @@
|
|
|
1
|
-
import { DataCursorInterface } from "../../
|
|
1
|
+
import { DataCursorInterface } from "../../Tools/DataCursor.interface";
|
|
2
2
|
import { Vec3Array, Vector3Like } from "@amodx/math";
|
|
3
3
|
import { VoxelCursor } from "../../Voxels/Cursor/VoxelCursor";
|
|
4
|
-
export declare class
|
|
4
|
+
export declare class VoxelGeometryBuilderCacheSpace {
|
|
5
5
|
bounds: Vector3Like;
|
|
6
6
|
foundHash: Uint8Array;
|
|
7
|
-
|
|
7
|
+
voxelCache: Uint16Array;
|
|
8
|
+
lightCache: Int32Array;
|
|
8
9
|
modCache: Int32Array;
|
|
9
10
|
stateCache: Int32Array;
|
|
10
11
|
conditonalStateCache: Int32Array;
|
|
11
12
|
noCastAO: Uint8Array;
|
|
12
13
|
offset: Vec3Array;
|
|
14
|
+
voxelCursor: VoxelCursor;
|
|
13
15
|
constructor(bounds: Vector3Like);
|
|
14
16
|
start(x: number, y: number, z: number): void;
|
|
15
17
|
getIndex(x: number, y: number, z: number): number;
|
|
16
18
|
getConstructor(index: number): import("./VoxelConstructor").VoxelConstructor | null;
|
|
17
19
|
getGeomtry(index: number): false | number[];
|
|
18
20
|
getConditionalGeomtry(index: number): false | number[][];
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
static voxelCursor: VoxelCursor;
|
|
23
|
-
static createSpace(x: number, y: number, z: number): VoxelGeometryLookUpSpace;
|
|
24
|
-
static init(): void;
|
|
25
|
-
static start(space: VoxelGeometryLookUpSpace): void;
|
|
26
|
-
static isRulesless(geoId: number): boolean;
|
|
27
|
-
static stop(): void;
|
|
28
|
-
static getHash(dataCursor: DataCursorInterface, x: number, y: number, z: number): number;
|
|
29
|
-
private static hashState;
|
|
21
|
+
getHash(dataCursor: DataCursorInterface, x: number, y: number, z: number): number;
|
|
22
|
+
getLight(dataCursor: DataCursorInterface, x: number, y: number, z: number): number;
|
|
23
|
+
private hashState;
|
|
30
24
|
}
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import { VoxelModelConstructorRegister } from "./VoxelModelConstructorRegister";
|
|
2
2
|
import { VoxelCursor } from "../../Voxels/Cursor/VoxelCursor";
|
|
3
3
|
import { GetYXZOrderArrayIndex } from "../../Math/Indexing";
|
|
4
|
-
export class
|
|
4
|
+
export class VoxelGeometryBuilderCacheSpace {
|
|
5
5
|
bounds;
|
|
6
6
|
foundHash;
|
|
7
|
-
|
|
7
|
+
voxelCache;
|
|
8
|
+
lightCache;
|
|
8
9
|
modCache;
|
|
9
10
|
stateCache;
|
|
10
11
|
conditonalStateCache;
|
|
11
12
|
noCastAO;
|
|
12
13
|
offset = [0, 0, 0];
|
|
14
|
+
voxelCursor = new VoxelCursor();
|
|
13
15
|
constructor(bounds) {
|
|
14
16
|
this.bounds = bounds;
|
|
15
17
|
const volume = bounds.x * bounds.y * bounds.z;
|
|
16
18
|
this.foundHash = new Uint8Array(volume);
|
|
17
|
-
this.
|
|
19
|
+
this.lightCache = new Int32Array(volume);
|
|
20
|
+
this.voxelCache = new Uint16Array(volume);
|
|
18
21
|
this.modCache = new Int32Array(volume);
|
|
19
22
|
this.stateCache = new Int32Array(volume);
|
|
20
23
|
this.conditonalStateCache = new Int32Array(volume);
|
|
@@ -24,8 +27,9 @@ export class VoxelGeometryLookUpSpace {
|
|
|
24
27
|
this.offset[0] = x;
|
|
25
28
|
this.offset[1] = y;
|
|
26
29
|
this.offset[2] = z;
|
|
30
|
+
this.lightCache.fill(-1);
|
|
27
31
|
this.foundHash.fill(0);
|
|
28
|
-
this.
|
|
32
|
+
this.voxelCache.fill(0);
|
|
29
33
|
this.modCache.fill(-1);
|
|
30
34
|
this.stateCache.fill(-1);
|
|
31
35
|
this.conditonalStateCache.fill(-1);
|
|
@@ -35,72 +39,73 @@ export class VoxelGeometryLookUpSpace {
|
|
|
35
39
|
return GetYXZOrderArrayIndex(x - this.offset[0], y - this.offset[1], z - this.offset[2], this.bounds.x, this.bounds.y, this.bounds.z);
|
|
36
40
|
}
|
|
37
41
|
getConstructor(index) {
|
|
38
|
-
if (this.foundHash[index]
|
|
42
|
+
if (this.foundHash[index] < 2)
|
|
39
43
|
return null;
|
|
40
|
-
return VoxelModelConstructorRegister.constructorsPaltte[this.
|
|
44
|
+
return VoxelModelConstructorRegister.constructorsPaltte[this.voxelCache[index]];
|
|
41
45
|
}
|
|
42
46
|
getGeomtry(index) {
|
|
43
|
-
if (this.foundHash[index]
|
|
47
|
+
if (this.foundHash[index] < 2)
|
|
44
48
|
return false;
|
|
45
|
-
return VoxelModelConstructorRegister.constructorsPaltte[this.
|
|
49
|
+
return VoxelModelConstructorRegister.constructorsPaltte[this.voxelCache[index]].data.shapeStateGeometryMap[this.stateCache[index]];
|
|
46
50
|
}
|
|
47
51
|
getConditionalGeomtry(index) {
|
|
48
|
-
if (this.foundHash[index]
|
|
52
|
+
if (this.foundHash[index] < 2)
|
|
49
53
|
return false;
|
|
50
|
-
return VoxelModelConstructorRegister.constructorsPaltte[this.
|
|
54
|
+
return VoxelModelConstructorRegister.constructorsPaltte[this.voxelCache[index]].data.condiotnalShapeStateGeometryMap[this.conditonalStateCache[index]];
|
|
51
55
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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;
|
|
62
|
-
}
|
|
63
|
-
static isRulesless(geoId) {
|
|
64
|
-
return VoxelModelConstructorRegister.rulesless[geoId] == true;
|
|
65
|
-
}
|
|
66
|
-
static stop() { }
|
|
67
|
-
static getHash(dataCursor, x, y, z) {
|
|
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) {
|
|
56
|
+
getHash(dataCursor, x, y, z) {
|
|
57
|
+
const hashed = this.getIndex(x, y, z);
|
|
58
|
+
if (this.foundHash[hashed] == 0) {
|
|
72
59
|
this.hashState(dataCursor, hashed, x, y, z);
|
|
73
60
|
}
|
|
74
61
|
return hashed;
|
|
75
62
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
63
|
+
getLight(dataCursor, x, y, z) {
|
|
64
|
+
const index = this.getIndex(x, y, z);
|
|
65
|
+
if (this.lightCache[index] == -1) {
|
|
66
|
+
this.lightCache[index] = 0;
|
|
67
|
+
const voxel = dataCursor.getVoxel(x, y, z);
|
|
68
|
+
if (voxel) {
|
|
69
|
+
const light = voxel.getLight();
|
|
70
|
+
if (light > 0) {
|
|
71
|
+
this.lightCache[index] = light;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return this.lightCache[index];
|
|
76
|
+
}
|
|
77
|
+
hashState(dataCursor, index, x, y, z) {
|
|
78
|
+
if (this.foundHash[index] == 1)
|
|
80
79
|
return -1;
|
|
81
|
-
if (this.
|
|
82
|
-
return this.
|
|
80
|
+
if (this.foundHash[index] == 2)
|
|
81
|
+
return this.stateCache[index];
|
|
83
82
|
const voxel = dataCursor.getVoxel(x, y, z);
|
|
83
|
+
if (voxel) {
|
|
84
|
+
const light = voxel.getLight();
|
|
85
|
+
if (light > 0) {
|
|
86
|
+
this.lightCache[index] = light;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
84
89
|
if (!voxel || !voxel.isRenderable()) {
|
|
85
|
-
this.
|
|
90
|
+
this.foundHash[index] = 1;
|
|
86
91
|
return -1;
|
|
87
92
|
}
|
|
88
93
|
const voxelId = voxel.getId();
|
|
89
94
|
const voxelConstructor = VoxelModelConstructorRegister.constructorsPaltte[voxelId];
|
|
90
95
|
if (!voxelConstructor) {
|
|
91
|
-
this.
|
|
96
|
+
this.foundHash[index] = 1;
|
|
92
97
|
return -1;
|
|
93
98
|
}
|
|
94
|
-
this.
|
|
95
|
-
this.
|
|
99
|
+
this.voxelCache[index] = voxelId;
|
|
100
|
+
this.foundHash[index] = 2;
|
|
96
101
|
//no ao
|
|
97
|
-
this.
|
|
102
|
+
this.noCastAO[index] = voxel.isLightSource() || voxel.noAO() ? 1 : 0;
|
|
98
103
|
//state
|
|
99
104
|
const state = voxelConstructor.shapeStateTree.getState(voxel.getState());
|
|
100
|
-
this.
|
|
105
|
+
this.stateCache[index] = state;
|
|
101
106
|
//mod
|
|
102
107
|
const mod = voxelConstructor.modTree.getState(voxel.getMod());
|
|
103
|
-
this.
|
|
108
|
+
this.modCache[index] = mod;
|
|
104
109
|
this.voxelCursor.copy(voxel).process();
|
|
105
110
|
voxelConstructor.schema.position.x = x;
|
|
106
111
|
voxelConstructor.schema.position.y = y;
|
|
@@ -108,7 +113,7 @@ export class VoxelGeometryLookUp {
|
|
|
108
113
|
voxelConstructor.schema.voxel = this.voxelCursor;
|
|
109
114
|
voxelConstructor.schema.dataCursor = dataCursor;
|
|
110
115
|
const conditonalState = voxelConstructor.condtioanlShapeStateTree.getState();
|
|
111
|
-
this.
|
|
116
|
+
this.conditonalStateCache[index] = conditonalState;
|
|
112
117
|
return 1;
|
|
113
118
|
}
|
|
114
119
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { VoxelPalette } from "../../Voxels/Palettes/VoxelPalette";
|
|
2
1
|
import { StringPalette } from "../../Util/StringPalette";
|
|
3
2
|
import { VoxelGeometryConstructor } from "./Nodes/VoxelGeometryConstructor";
|
|
3
|
+
import { VoxelPalettesRegister } from "../../Voxels/Data/VoxelPalettesRegister";
|
|
4
4
|
export class VoxelModelConstructorRegister {
|
|
5
5
|
static geometryPalette;
|
|
6
6
|
static geometry = [];
|
|
@@ -31,11 +31,11 @@ export class VoxelModelConstructorRegister {
|
|
|
31
31
|
if (Array.isArray(voxel)) {
|
|
32
32
|
for (const vox of voxel) {
|
|
33
33
|
this.constructors.set(vox.id, vox);
|
|
34
|
-
this.constructorsPaltte[
|
|
34
|
+
this.constructorsPaltte[VoxelPalettesRegister.voxels.getNumberId(vox.id)] = vox;
|
|
35
35
|
}
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
|
-
this.constructorsPaltte[
|
|
38
|
+
this.constructorsPaltte[VoxelPalettesRegister.voxels.getNumberId(voxel.id)] = voxel;
|
|
39
39
|
this.constructors.set(voxel.id, voxel);
|
|
40
40
|
}
|
|
41
41
|
static registerGeometry(geometries) {
|
|
@@ -56,9 +56,8 @@ export declare class StructCursor {
|
|
|
56
56
|
get active(): number;
|
|
57
57
|
get nodeType(): number;
|
|
58
58
|
trueIndex: number;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
set index(index: number);
|
|
59
|
+
private index;
|
|
60
|
+
setIndex(index: number): void;
|
|
62
61
|
constructor(data: Float32Array);
|
|
63
62
|
setActive(): void;
|
|
64
63
|
setVoxelIndex(value: number): void;
|
|
@@ -66,12 +65,6 @@ export declare class StructCursor {
|
|
|
66
65
|
setGeomtryNode(): void;
|
|
67
66
|
updateMin(x: number, y: number, z: number): void;
|
|
68
67
|
updateMax(x: number, y: number, z: number): void;
|
|
69
|
-
toJSON(): {
|
|
70
|
-
min: number[];
|
|
71
|
-
max: number[];
|
|
72
|
-
active: number;
|
|
73
|
-
nodeType: number;
|
|
74
|
-
};
|
|
75
68
|
}
|
|
76
69
|
export declare class VoxelMeshBVHBuilder {
|
|
77
70
|
static AABBStructByteSize: number;
|
|
@@ -134,12 +134,8 @@ export class StructCursor {
|
|
|
134
134
|
return this.data[this.trueIndex + 7];
|
|
135
135
|
}
|
|
136
136
|
trueIndex = 0;
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
return this._index;
|
|
140
|
-
}
|
|
141
|
-
set index(index) {
|
|
142
|
-
this._index = index;
|
|
137
|
+
index = 0;
|
|
138
|
+
setIndex(index) {
|
|
143
139
|
this.trueIndex = index * 8;
|
|
144
140
|
}
|
|
145
141
|
constructor(data) {
|
|
@@ -185,14 +181,6 @@ export class StructCursor {
|
|
|
185
181
|
this.data[iz] = z;
|
|
186
182
|
}
|
|
187
183
|
}
|
|
188
|
-
toJSON() {
|
|
189
|
-
return {
|
|
190
|
-
min: [this.minX, this.minY, this.minZ],
|
|
191
|
-
max: [this.maxX, this.maxY, this.maxZ],
|
|
192
|
-
active: this.active,
|
|
193
|
-
nodeType: this.nodeType,
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
184
|
}
|
|
197
185
|
export class VoxelMeshBVHBuilder {
|
|
198
186
|
static AABBStructByteSize = (4 + 4) * 4;
|
|
@@ -209,7 +197,7 @@ export class VoxelMeshBVHBuilder {
|
|
|
209
197
|
const leafIndex = this.treeIndex.getIndexAtLevel(12, voxelIndex);
|
|
210
198
|
this.indices[voxelIndex * 2] = indicesStart;
|
|
211
199
|
this.indices[voxelIndex * 2 + 1] = indicesEnd;
|
|
212
|
-
this.structCursor.
|
|
200
|
+
this.structCursor.setIndex(leafIndex);
|
|
213
201
|
this.structCursor.updateMin(minX, minY, minZ);
|
|
214
202
|
this.structCursor.updateMax(maxX, maxY, maxZ);
|
|
215
203
|
this.structCursor.setVoxelIndex(voxelIndex);
|
|
@@ -217,7 +205,7 @@ export class VoxelMeshBVHBuilder {
|
|
|
217
205
|
let current = leafIndex;
|
|
218
206
|
for (let level = 1; level < 13; level++) {
|
|
219
207
|
let parentNode = this.treeIndex.getParent(current);
|
|
220
|
-
this.structCursor.
|
|
208
|
+
this.structCursor.setIndex(parentNode);
|
|
221
209
|
this.structCursor.updateMin(minX, minY, minZ);
|
|
222
210
|
this.structCursor.updateMax(maxX, maxY, maxZ);
|
|
223
211
|
this.structCursor.setActive();
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
export declare const VoxelMeshVertexConstants: {
|
|
2
|
+
VertexFloatSize: number;
|
|
3
|
+
VertexByteSize: number;
|
|
4
|
+
PositionOffset: number;
|
|
5
|
+
NormalOffset: number;
|
|
6
|
+
TextureIndexOffset: number;
|
|
7
|
+
UVOffset: number;
|
|
8
|
+
ColorOffset: number;
|
|
9
|
+
VoxelDataOFfset: number;
|
|
10
|
+
};
|
|
1
11
|
export declare class VoxelMeshVertexStructCursor {
|
|
2
12
|
static VertexFloatSize: number;
|
|
3
13
|
static VertexByteSize: number;
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
export const VoxelMeshVertexConstants = {
|
|
2
|
+
VertexFloatSize: 24,
|
|
3
|
+
VertexByteSize: 24 * 4,
|
|
4
|
+
PositionOffset: 0,
|
|
5
|
+
NormalOffset: 4,
|
|
6
|
+
TextureIndexOffset: 8,
|
|
7
|
+
UVOffset: 12,
|
|
8
|
+
ColorOffset: 14,
|
|
9
|
+
VoxelDataOFfset: 18,
|
|
10
|
+
};
|
|
1
11
|
export class VoxelMeshVertexStructCursor {
|
|
2
12
|
static VertexFloatSize = 24;
|
|
3
13
|
static VertexByteSize = this.VertexFloatSize * 4;
|
|
@@ -4,22 +4,24 @@ import { VoxelFaces } from "../../Math";
|
|
|
4
4
|
import { QuadVerticies } from "../Geomtry/Geometry.types";
|
|
5
5
|
import { VoxelMesh } from "../Geomtry/VoxelMesh";
|
|
6
6
|
import { VoxelMeshBVHBuilder } from "./VoxelMeshBVHBuilder";
|
|
7
|
-
import { Vec3Array, Vector3Like } from "@amodx/math";
|
|
7
|
+
import { Vec3Array, Vector3Like, Vector4Like } from "@amodx/math";
|
|
8
8
|
import { VoxelCursorInterface } from "../../Voxels/Cursor/VoxelCursor.interface.js";
|
|
9
|
-
import { DataCursorInterface } from "../../
|
|
9
|
+
import { DataCursorInterface } from "../../Tools/DataCursor.interface.js";
|
|
10
|
+
import { VoxelGeometryBuilderCacheSpace } from "../Models/VoxelGeometryBuilderCacheSpace";
|
|
10
11
|
declare class VoxelVars {
|
|
11
12
|
faceFlipped: boolean;
|
|
12
13
|
textureIndex: number;
|
|
14
|
+
overlayTextures: Vector4Like;
|
|
13
15
|
light: QuadScalarVertexData;
|
|
14
16
|
ao: QuadScalarVertexData;
|
|
15
17
|
animation: QuadScalarVertexData;
|
|
16
18
|
level: QuadScalarVertexData;
|
|
17
|
-
overlayTextures: QuadScalarVertexData;
|
|
18
19
|
reset(): void;
|
|
19
20
|
}
|
|
20
21
|
export declare class VoxelMesherDataTool extends MesherDataTool {
|
|
21
22
|
id: string;
|
|
22
23
|
materialIndex: number;
|
|
24
|
+
space: VoxelGeometryBuilderCacheSpace;
|
|
23
25
|
voxel: VoxelCursorInterface;
|
|
24
26
|
nVoxel: DataCursorInterface;
|
|
25
27
|
/**The current world position */
|
|
@@ -41,9 +43,10 @@ export declare class VoxelMesherDataTool extends MesherDataTool {
|
|
|
41
43
|
_indexStart: number;
|
|
42
44
|
startConstruction(): void;
|
|
43
45
|
endConstruction(): boolean;
|
|
46
|
+
_boundsUpdate: boolean;
|
|
47
|
+
updateBounds(bounds: [Vec3Array, Vec3Array]): void;
|
|
44
48
|
calculateFaceData(direction: VoxelFaces): true | undefined;
|
|
45
49
|
clearCalculatedData(): void;
|
|
46
|
-
|
|
47
|
-
resetAll(): this;
|
|
50
|
+
clear(): this;
|
|
48
51
|
}
|
|
49
52
|
export {};
|