@divinevoxel/vlox 0.0.72 → 0.0.73
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 +1 -1
- package/Contexts/World/DivineVoxelEngineWorld.d.ts +1 -1
- package/Init/StartConstructor.js +6 -4
- package/Init/StartWorld.d.ts +1 -1
- package/Mesher/Functions/CompactVoxelMesh.d.ts +2 -2
- package/Mesher/Functions/CompactVoxelMesh.js +1 -1
- package/Mesher/Functions/MeshSection.js +20 -8
- package/Mesher/Functions/MeshTexture.d.ts +1 -1
- package/Mesher/Functions/MeshTexture.js +3 -4
- package/Mesher/Geomtry/Primitives/QuadVertexData.d.ts +12 -10
- package/Mesher/Geomtry/Primitives/QuadVertexData.js +49 -56
- package/Mesher/Geomtry/VoxelGeometryBuilder.d.ts +2 -2
- package/Mesher/Geomtry/VoxelGeometryBuilder.js +2 -2
- package/Mesher/Geomtry/VoxelMesh.d.ts +1 -1
- package/Mesher/Geomtry/VoxelMesh.js +2 -2
- package/Mesher/Geomtry/index.d.ts +0 -1
- package/Mesher/Geomtry/index.js +0 -1
- package/Mesher/InitMesher.js +1 -1
- package/Mesher/InitTask.js +4 -22
- package/Mesher/Models/Common/Calc/FaceDataCalc.d.ts +2 -2
- package/Mesher/Models/Common/Calc/FaceDataCalc.js +37 -30
- package/Mesher/Models/Nodes/Custom/Liquid/FlowGradient.d.ts +2 -2
- package/Mesher/Models/Nodes/Custom/Liquid/FlowGradient.js +1 -1
- package/Mesher/Models/Nodes/Custom/Liquid/LiquidGeomtryNode.js +11 -17
- package/Mesher/Models/Nodes/GeometryNode.d.ts +2 -2
- package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.d.ts +1 -0
- package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.js +24 -12
- package/Mesher/{Tools → Models/Protocols}/OutlinedVoxelTool.d.ts +1 -1
- package/Mesher/{Tools → Models/Protocols}/OutlinedVoxelTool.js +1 -1
- package/Mesher/Models/RenderedMaterials.d.ts +6 -0
- package/Mesher/{RenderedMaterials.js → Models/RenderedMaterials.js} +2 -2
- package/Mesher/Models/VoxelConstructor.d.ts +3 -3
- package/Mesher/Models/VoxelGeometryBuilderCacheSpace.d.ts +1 -3
- package/Mesher/Models/VoxelGeometryBuilderCacheSpace.js +0 -23
- package/Mesher/{Tools/VoxelMesherDataTool.d.ts → Models/VoxelModelBuilder.d.ts} +4 -5
- package/Mesher/{Tools/VoxelMesherDataTool.js → Models/VoxelModelBuilder.js} +11 -7
- package/Models/Defaults/CubeVoxelGeometry.js +4 -0
- package/Models/Defaults/CubeVoxelModels.js +344 -344
- package/Models/Defaults/LiquidVoxelModel.js +2 -2
- package/Models/Defaults/PanelVoxelModels.js +432 -432
- package/Models/Defaults/StairVoxelModel.js +576 -576
- package/Models/Examples.js +469 -456
- package/Models/Rules/Functions/BuildFinalInputs.js +9 -7
- package/Models/Rules/Functions/BuildGeomtryInputs.js +8 -5
- package/Models/Rules/Functions/BuildRules.js +2 -2
- package/Models/Rules/{VoxelModelManager.d.ts → VoxelModelRuleBuilderRegister.d.ts} +1 -1
- package/Models/Rules/VoxelModelRuleBuilderRegister.js +178 -0
- package/Models/VoxelModel.types.d.ts +14 -5
- package/Renderer/Classes/SectorMesh.d.ts +3 -4
- package/Renderer/Classes/SectorMesh.js +6 -11
- package/Renderer/InitTasks.js +6 -7
- package/Renderer/MeshManager.js +2 -2
- package/Renderer/MeshRegister.js +2 -1
- package/Settings/EngineSettings.d.ts +1 -1
- package/Settings/EngineSettings.js +3 -5
- package/Settings/EngineSettings.types.d.ts +17 -18
- package/Settings/EngineSettings.types.js +16 -15
- package/Tasks/IWG/IWG.d.ts +2 -1
- package/Tasks/IWG/IWG.js +9 -3
- package/Tasks/IWG/Internal/Classes/BuildQueue.d.ts +11 -0
- package/Tasks/IWG/Internal/Classes/BuildQueue.js +49 -0
- package/Tasks/IWG/Internal/Classes/Generator.d.ts +6 -1
- package/Tasks/IWG/Internal/Classes/Generator.js +13 -1
- package/Tasks/IWG/Internal/Classes/IWGTaskBase.js +2 -2
- package/Tasks/IWG/Internal/Functions/runBuildUpdate.js +21 -2
- package/Tasks/IWG/Internal/IWGTasks.d.ts +0 -4
- package/Tasks/IWG/Internal/IWGTasks.js +0 -10
- package/Tasks/IWG/Internal/IWGTools.d.ts +1 -1
- package/Tasks/IWG/Procedures/SaveAllSectors.js +2 -0
- package/Tasks/Update/UpdateTask.d.ts +3 -1
- package/Tasks/Update/UpdateTask.js +28 -2
- package/Tasks/Update/VoxelUpdate.js +6 -0
- package/Tasks/WorldGeneration/WorldGenBrush.js +1 -1
- package/Templates/Cursor/TemplateCursor.d.ts +2 -2
- package/Templates/Cursor/TemplateCursor.js +1 -2
- package/Templates/VoxelTemplates.types.d.ts +1 -1
- package/Textures/Classes/CompiledTexture.d.ts +18 -0
- package/Textures/Classes/CompiledTexture.js +50 -0
- package/Textures/Classes/CompiledTextureAnimation.d.ts +12 -0
- package/Textures/Classes/CompiledTextureAnimation.js +27 -0
- package/Textures/Classes/TextureAnimationTexture.d.ts +10 -0
- package/Textures/Classes/TextureAnimationTexture.js +32 -0
- package/Textures/Functions/BuildTextureData.d.ts +10 -0
- package/Textures/Functions/BuildTextureData.js +205 -0
- package/Textures/Texture.types.d.ts +50 -64
- package/Textures/TextureManager.d.ts +8 -19
- package/Textures/TextureManager.js +28 -166
- package/Tools/Brush/Brush.d.ts +1 -1
- package/Tools/Brush/Brush.js +39 -7
- package/Util/Binary/BinaryArrays.d.ts +6 -0
- package/Util/Binary/BinaryArrays.js +25 -0
- package/Util/Binary/BinaryBuffer.d.ts +29 -0
- package/Util/Binary/BinaryBuffer.js +130 -0
- package/Util/Binary/{BitArray.d.ts → BinaryFunctions.d.ts} +1 -2
- package/Util/Binary/BinaryFunctions.js +11 -0
- package/Voxels/Cursor/DataCursor.interface.d.ts +5 -0
- package/Voxels/Cursor/VoxelCursor.interface.d.ts +1 -1
- package/Voxels/Cursor/VoxelCursor.interface.js +8 -11
- package/Voxels/Data/VoxelPalettesRegister.d.ts +0 -5
- package/Voxels/Data/VoxelPalettesRegister.js +0 -9
- package/Voxels/Data/VoxelTagsRegister.js +7 -7
- package/Voxels/Functions/BuildStateData.js +9 -9
- package/Voxels/Functions/BuildTagAndPaletteData.js +2 -4
- package/Voxels/InitVoxelData.js +12 -13
- package/Voxels/State/Schema/StateSchema.d.ts +1 -1
- package/Voxels/Types/Voxel.types.d.ts +18 -0
- package/Voxels/Types/Voxel.types.js +6 -2
- package/World/Archive/Archive.types.d.ts +38 -34
- package/World/Archive/Functions/ArchiveArea.js +16 -24
- package/World/Archive/Functions/ArchiveSector.js +477 -192
- package/World/Archive/Functions/ImportSector.d.ts +3 -3
- package/World/Archive/Functions/ImportSector.js +202 -141
- package/World/Archive/Functions/Shared.d.ts +6 -0
- package/World/Archive/Functions/Shared.js +75 -0
- package/World/Archive/InitTasks.js +30 -13
- package/World/Cursor/SectionCursor.d.ts +2 -2
- package/World/Cursor/SectionCursor.js +2 -3
- package/World/Cursor/SectorCursor.d.ts +2 -2
- package/World/Cursor/SectorCursor.js +1 -2
- package/World/Cursor/WorldCursor.d.ts +2 -2
- package/World/Cursor/WorldCursor.js +1 -2
- package/World/Cursor/WorldVoxelCursor.js +1 -0
- package/World/InitTasks.d.ts +1 -1
- package/World/Lock/WorldLock.d.ts +1 -1
- package/World/Section/Section.d.ts +12 -16
- package/World/Section/Section.js +62 -20
- package/World/Section/SectionState.d.ts +10 -0
- package/World/Section/SectionState.js +11 -0
- package/World/Sector/Sector.d.ts +14 -6
- package/World/Sector/Sector.js +67 -17
- package/World/Sector/SectorHeightMap.js +2 -2
- package/World/Sector/SectorState.d.ts +14 -6
- package/World/Sector/SectorState.js +28 -15
- package/World/Types/WorldStorage.interface.js +1 -0
- package/World/WorldRegister.d.ts +4 -0
- package/World/WorldRegister.js +15 -3
- package/World/WorldSpaces.d.ts +4 -0
- package/World/WorldSpaces.js +19 -6
- package/package.json +1 -1
- package/Mesher/Functions/CompactMesh.d.ts +0 -2
- package/Mesher/Functions/CompactMesh.js +0 -42
- package/Mesher/Geomtry/GeometryNormals.d.ts +0 -10
- package/Mesher/Geomtry/GeometryNormals.js +0 -52
- package/Mesher/Geomtry/MeshData.types.d.ts +0 -13
- package/Mesher/Geomtry/MeshData.types.js +0 -6
- package/Mesher/Geomtry/Tools/MesherDataTools.d.ts +0 -7
- package/Mesher/Geomtry/Tools/MesherDataTools.js +0 -12
- package/Mesher/Geomtry/Tools/index.d.ts +0 -1
- package/Mesher/Geomtry/Tools/index.js +0 -1
- package/Mesher/RenderedMaterials.d.ts +0 -6
- package/Models/Rules/VoxelModelManager.js +0 -82
- package/Textures/TextureAnimations.d.ts +0 -4
- package/Textures/TextureAnimations.js +0 -35
- package/Textures/TextureArray.d.ts +0 -47
- package/Textures/TextureArray.js +0 -202
- package/Textures/TextureBuilder.d.ts +0 -13
- package/Textures/TextureBuilder.js +0 -120
- package/Textures/TextureRegister.d.ts +0 -9
- package/Textures/TextureRegister.js +0 -28
- package/Tools/DataCursor.interface.d.ts +0 -5
- package/Tools/DataCursor.interface.js +0 -2
- package/Util/Binary/BitArray.js +0 -16
- package/World/Structs/WorldDataStructProperties.d.ts +0 -8
- package/World/Structs/WorldDataStructProperties.js +0 -9
- /package/Mesher/{Tools → Geomtry}/VoxelMeshBVHBuilder.d.ts +0 -0
- /package/Mesher/{Tools → Geomtry}/VoxelMeshBVHBuilder.js +0 -0
- /package/Mesher/Geomtry/{Buffers.d.ts → VoxelMeshBuffers.d.ts} +0 -0
- /package/Mesher/Geomtry/{Buffers.js → VoxelMeshBuffers.js} +0 -0
- /package/Mesher/{Tools → Geomtry}/VoxelMeshVertexStructCursor.d.ts +0 -0
- /package/Mesher/{Tools → Geomtry}/VoxelMeshVertexStructCursor.js +0 -0
- /package/Mesher/{VoxelShaderData.d.ts → Geomtry/VoxelShaderData.d.ts} +0 -0
- /package/Mesher/{VoxelShaderData.js → Geomtry/VoxelShaderData.js} +0 -0
- /package/{World/Storage/WorldStorage.interface.js → Voxels/Cursor/DataCursor.interface.js} +0 -0
- /package/World/{Storage → Types}/WorldStorage.interface.d.ts +0 -0
|
@@ -49,12 +49,13 @@ export class LiquidGeometryNode extends GeoemtryNode {
|
|
|
49
49
|
return false;
|
|
50
50
|
}
|
|
51
51
|
determineShading(face) {
|
|
52
|
-
|
|
53
|
-
const lightData =
|
|
52
|
+
this.builder.calculateFaceData(face);
|
|
53
|
+
const lightData = this.builder.lightData[face];
|
|
54
54
|
const worldLight = this.builder.vars.light;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
worldLight.vertices[0] = lightData[0];
|
|
56
|
+
worldLight.vertices[1] = lightData[1];
|
|
57
|
+
worldLight.vertices[2] = lightData[2];
|
|
58
|
+
worldLight.vertices[3] = lightData[3];
|
|
58
59
|
}
|
|
59
60
|
shouldFlip() {
|
|
60
61
|
const worldLight = this.builder.vars.light;
|
|
@@ -72,7 +73,6 @@ export class LiquidGeometryNode extends GeoemtryNode {
|
|
|
72
73
|
added = true;
|
|
73
74
|
getFlowGradient(tool, vertexLevel);
|
|
74
75
|
const quad = Quads[VoxelFaces.Up];
|
|
75
|
-
tool.calculateFaceData(VoxelFaces.Up);
|
|
76
76
|
this.determineShading(VoxelFaces.Up);
|
|
77
77
|
quad.flip = this.shouldFlip();
|
|
78
78
|
tool.vars.textureIndex = args.stillTexture;
|
|
@@ -99,19 +99,16 @@ export class LiquidGeometryNode extends GeoemtryNode {
|
|
|
99
99
|
added = true;
|
|
100
100
|
tool.vars.textureIndex = args.stillTexture;
|
|
101
101
|
const quad = Quads[VoxelFaces.Down];
|
|
102
|
-
tool.calculateFaceData(VoxelFaces.Down);
|
|
103
102
|
this.determineShading(VoxelFaces.Down);
|
|
104
103
|
quad.flip = this.shouldFlip();
|
|
105
|
-
tool.vars.textureIndex = args.stillTexture;
|
|
106
104
|
VoxelGeometryBuilder.addQuad(tool, tool.origin, quad);
|
|
107
105
|
tool.updateBounds(quadBounds[VoxelFaces.Down]);
|
|
108
106
|
}
|
|
109
107
|
if (this.isExposed(VoxelFaces.North)) {
|
|
110
108
|
added = true;
|
|
111
|
-
tool.vars.textureIndex = args.
|
|
109
|
+
tool.vars.textureIndex = args.flowTexture;
|
|
112
110
|
const quad = Quads[VoxelFaces.North];
|
|
113
111
|
tool.vars.animation.setAll(1);
|
|
114
|
-
tool.calculateFaceData(VoxelFaces.North);
|
|
115
112
|
this.determineShading(VoxelFaces.North);
|
|
116
113
|
quad.flip = this.shouldFlip();
|
|
117
114
|
if (upFaceExposed) {
|
|
@@ -134,10 +131,9 @@ export class LiquidGeometryNode extends GeoemtryNode {
|
|
|
134
131
|
}
|
|
135
132
|
if (this.isExposed(VoxelFaces.South)) {
|
|
136
133
|
added = true;
|
|
137
|
-
tool.vars.textureIndex = args.
|
|
134
|
+
tool.vars.textureIndex = args.flowTexture;
|
|
138
135
|
const quad = Quads[VoxelFaces.South];
|
|
139
136
|
tool.vars.animation.setAll(1);
|
|
140
|
-
tool.calculateFaceData(VoxelFaces.South);
|
|
141
137
|
this.determineShading(VoxelFaces.South);
|
|
142
138
|
quad.flip = this.shouldFlip();
|
|
143
139
|
if (upFaceExposed) {
|
|
@@ -160,12 +156,11 @@ export class LiquidGeometryNode extends GeoemtryNode {
|
|
|
160
156
|
}
|
|
161
157
|
if (this.isExposed(VoxelFaces.East)) {
|
|
162
158
|
added = true;
|
|
163
|
-
tool.vars.textureIndex = args.
|
|
159
|
+
tool.vars.textureIndex = args.flowTexture;
|
|
164
160
|
const quad = Quads[VoxelFaces.East];
|
|
165
161
|
tool.vars.animation.setAll(1);
|
|
166
|
-
tool.calculateFaceData(VoxelFaces.East);
|
|
167
162
|
this.determineShading(VoxelFaces.East);
|
|
168
|
-
|
|
163
|
+
quad.flip = this.shouldFlip();
|
|
169
164
|
if (upFaceExposed) {
|
|
170
165
|
quad.positions.vertices[QuadVerticies.TopRight].y =
|
|
171
166
|
vertexValue.vertices[FlowVerticies.NorthEast] * waterHeight;
|
|
@@ -186,10 +181,9 @@ export class LiquidGeometryNode extends GeoemtryNode {
|
|
|
186
181
|
}
|
|
187
182
|
if (this.isExposed(VoxelFaces.West)) {
|
|
188
183
|
added = true;
|
|
189
|
-
tool.vars.textureIndex = args.
|
|
184
|
+
tool.vars.textureIndex = args.flowTexture;
|
|
190
185
|
const quad = Quads[VoxelFaces.West];
|
|
191
186
|
tool.vars.animation.setAll(1);
|
|
192
|
-
tool.calculateFaceData(VoxelFaces.West);
|
|
193
187
|
this.determineShading(VoxelFaces.West);
|
|
194
188
|
quad.flip = this.shouldFlip();
|
|
195
189
|
if (upFaceExposed) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { VoxelModelBuilder } from "../VoxelModelBuilder";
|
|
2
2
|
import { VoxelGeometryConstructor } from "./VoxelGeometryConstructor";
|
|
3
3
|
import { VoxelGeometryTransform } from "../../../Voxels/Types/VoxelModelCompiledData.types";
|
|
4
4
|
export interface GeoemtryNodeConstructor<Data = any, Args = any> {
|
|
@@ -13,7 +13,7 @@ export declare abstract class GeoemtryNode<Data = any, Args = any> {
|
|
|
13
13
|
vertexIndex: number;
|
|
14
14
|
faceCount: number;
|
|
15
15
|
vertexCount: number;
|
|
16
|
-
builder:
|
|
16
|
+
builder: VoxelModelBuilder;
|
|
17
17
|
constructor(geometryPaletteId: number, geomtry: VoxelGeometryConstructor, data: Data, transform: VoxelGeometryTransform);
|
|
18
18
|
abstract init(): void;
|
|
19
19
|
abstract add(args: Args): boolean;
|
|
@@ -11,6 +11,7 @@ export class BoxVoxelGometryNode extends GeoemtryNode {
|
|
|
11
11
|
quads;
|
|
12
12
|
quadBounds = [];
|
|
13
13
|
vertexWeights;
|
|
14
|
+
_wasAOShaded = false;
|
|
14
15
|
lightData = new VoxelLightData();
|
|
15
16
|
init() {
|
|
16
17
|
this.faceCount = 6;
|
|
@@ -41,8 +42,8 @@ export class BoxVoxelGometryNode extends GeoemtryNode {
|
|
|
41
42
|
continue;
|
|
42
43
|
const faceIndex = this.geomtry.cullIndex.getValue(geoId, currentIndex, trueFaceIndex);
|
|
43
44
|
if (faceIndex > -1 &&
|
|
44
|
-
!this.builder
|
|
45
|
-
.
|
|
45
|
+
!this.builder.space
|
|
46
|
+
.getConstructor(hashed)
|
|
46
47
|
?.isShapeStateFaceTransparent(this.builder.space.modCache[hashed], this.builder.space.stateCache[hashed], geoId, faceIndex)) {
|
|
47
48
|
return false;
|
|
48
49
|
}
|
|
@@ -58,8 +59,8 @@ export class BoxVoxelGometryNode extends GeoemtryNode {
|
|
|
58
59
|
continue;
|
|
59
60
|
const faceIndex = this.geomtry.cullIndex.getValue(geoId, currentIndex, trueFaceIndex);
|
|
60
61
|
if (faceIndex > -1 &&
|
|
61
|
-
!this.builder
|
|
62
|
-
.
|
|
62
|
+
!this.builder.space
|
|
63
|
+
.getConstructor(hashed)
|
|
63
64
|
?.isCondtionalStateFaceTransparent(this.builder.space.modCache[hashed], this.builder.space.stateCache[hashed], geoId, faceIndex))
|
|
64
65
|
return false;
|
|
65
66
|
}
|
|
@@ -99,21 +100,28 @@ export class BoxVoxelGometryNode extends GeoemtryNode {
|
|
|
99
100
|
length = baseGeo.length;
|
|
100
101
|
for (let geoIndex = 0; geoIndex < length; geoIndex++) {
|
|
101
102
|
if (this.geomtry.aoIndex.getValue(baseGeo[geoIndex], currentIndex, trueVertexIndex)) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
this._wasAOShaded = true;
|
|
104
|
+
worldAO.vertices[v]++;
|
|
105
|
+
if (worldAO.vertices[v] > 4) {
|
|
106
|
+
shaded = true;
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
105
109
|
}
|
|
106
110
|
}
|
|
107
111
|
}
|
|
108
|
-
if (!conditonalGeo)
|
|
112
|
+
if (!conditonalGeo || shaded)
|
|
109
113
|
continue;
|
|
110
114
|
length = conditonalGeo.length;
|
|
111
115
|
for (let condtionsIndex = 0; condtionsIndex < length; condtionsIndex++) {
|
|
112
116
|
const condiotnalength = conditonalGeo[condtionsIndex].length;
|
|
113
117
|
for (let geoIndex = 0; geoIndex < condiotnalength; geoIndex++) {
|
|
114
118
|
if (this.geomtry.aoIndex.getValue(conditonalGeo[condtionsIndex][geoIndex], currentIndex, trueVertexIndex)) {
|
|
115
|
-
|
|
116
|
-
|
|
119
|
+
this._wasAOShaded = true;
|
|
120
|
+
worldAO.vertices[v]++;
|
|
121
|
+
if (worldAO.vertices[v] > 4) {
|
|
122
|
+
shaded = true;
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
117
125
|
}
|
|
118
126
|
}
|
|
119
127
|
}
|
|
@@ -122,9 +130,12 @@ export class BoxVoxelGometryNode extends GeoemtryNode {
|
|
|
122
130
|
}
|
|
123
131
|
shouldFlip() {
|
|
124
132
|
const worldAO = this.builder.vars.ao;
|
|
125
|
-
|
|
126
|
-
|
|
133
|
+
if (shouldCauseFlip(worldAO.vertices[0], worldAO.vertices[1], worldAO.vertices[2], worldAO.vertices[3]) &&
|
|
134
|
+
this._wasAOShaded)
|
|
127
135
|
return true;
|
|
136
|
+
if (this._wasAOShaded)
|
|
137
|
+
return false;
|
|
138
|
+
const worldLight = this.builder.vars.light;
|
|
128
139
|
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])) ||
|
|
129
140
|
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])));
|
|
130
141
|
}
|
|
@@ -159,6 +170,7 @@ export class BoxVoxelGometryNode extends GeoemtryNode {
|
|
|
159
170
|
}
|
|
160
171
|
this.builder.vars.ao.setAll(0);
|
|
161
172
|
this.builder.vars.light.setAll(0);
|
|
173
|
+
this._wasAOShaded = false;
|
|
162
174
|
return added;
|
|
163
175
|
}
|
|
164
176
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { VoxelModelBuilder } from "./VoxelModelBuilder";
|
|
2
2
|
export class RenderedMaterials {
|
|
3
3
|
static meshersMap = new Map();
|
|
4
4
|
static meshers = [];
|
|
5
5
|
static register(materials) {
|
|
6
6
|
for (let i = 0; i < materials.length; i++) {
|
|
7
|
-
const newTool = new
|
|
7
|
+
const newTool = new VoxelModelBuilder(materials[i], i);
|
|
8
8
|
this.meshersMap.set(materials[i], newTool);
|
|
9
9
|
this.meshers[i] = newTool;
|
|
10
10
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { VoxelModelBuilder } from "./VoxelModelBuilder";
|
|
2
2
|
import { CompiledVoxelModelInputData, CompiledVoxelModelData } from "../../Voxels/Types/VoxelModelCompiledData.types";
|
|
3
3
|
import { StateSchema } from "../../Voxels/State/Schema/StateSchema";
|
|
4
4
|
import { StateTreeReader } from "../../Voxels/State/StateTreeReader";
|
|
@@ -7,7 +7,7 @@ import { VoxelModelEffect } from "./VoxelModelEffect";
|
|
|
7
7
|
import { CondtionalTreeReader } from "../../Voxels/State/CondiotnalTreeReader";
|
|
8
8
|
export declare class VoxelConstructor {
|
|
9
9
|
id: string;
|
|
10
|
-
builder:
|
|
10
|
+
builder: VoxelModelBuilder;
|
|
11
11
|
data: CompiledVoxelModelData;
|
|
12
12
|
isModel: true;
|
|
13
13
|
geometries: number[][];
|
|
@@ -20,7 +20,7 @@ export declare class VoxelConstructor {
|
|
|
20
20
|
effects: VoxelModelEffect;
|
|
21
21
|
shapeStateTree: StateTreeReader;
|
|
22
22
|
condtioanlShapeStateTree: CondtionalTreeReader;
|
|
23
|
-
constructor(id: string, builder:
|
|
23
|
+
constructor(id: string, builder: VoxelModelBuilder, 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
26
|
process(): boolean;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { DataCursorInterface } from "../../
|
|
1
|
+
import { DataCursorInterface } from "../../Voxels/Cursor/DataCursor.interface";
|
|
2
2
|
import { Vec3Array, Vector3Like } from "@amodx/math";
|
|
3
3
|
import { VoxelCursor } from "../../Voxels/Cursor/VoxelCursor";
|
|
4
4
|
export declare class VoxelGeometryBuilderCacheSpace {
|
|
5
5
|
bounds: Vector3Like;
|
|
6
6
|
foundHash: Uint8Array;
|
|
7
7
|
voxelCache: Uint16Array;
|
|
8
|
-
lightCache: Int32Array;
|
|
9
8
|
modCache: Int32Array;
|
|
10
9
|
stateCache: Int32Array;
|
|
11
10
|
conditonalStateCache: Int32Array;
|
|
@@ -19,6 +18,5 @@ export declare class VoxelGeometryBuilderCacheSpace {
|
|
|
19
18
|
getGeomtry(index: number): false | number[];
|
|
20
19
|
getConditionalGeomtry(index: number): false | number[][];
|
|
21
20
|
getHash(dataCursor: DataCursorInterface, x: number, y: number, z: number): number;
|
|
22
|
-
getLight(dataCursor: DataCursorInterface, x: number, y: number, z: number): number;
|
|
23
21
|
private hashState;
|
|
24
22
|
}
|
|
@@ -5,7 +5,6 @@ export class VoxelGeometryBuilderCacheSpace {
|
|
|
5
5
|
bounds;
|
|
6
6
|
foundHash;
|
|
7
7
|
voxelCache;
|
|
8
|
-
lightCache;
|
|
9
8
|
modCache;
|
|
10
9
|
stateCache;
|
|
11
10
|
conditonalStateCache;
|
|
@@ -16,7 +15,6 @@ export class VoxelGeometryBuilderCacheSpace {
|
|
|
16
15
|
this.bounds = bounds;
|
|
17
16
|
const volume = bounds.x * bounds.y * bounds.z;
|
|
18
17
|
this.foundHash = new Uint8Array(volume);
|
|
19
|
-
this.lightCache = new Int32Array(volume);
|
|
20
18
|
this.voxelCache = new Uint16Array(volume);
|
|
21
19
|
this.modCache = new Int32Array(volume);
|
|
22
20
|
this.stateCache = new Int32Array(volume);
|
|
@@ -27,7 +25,6 @@ export class VoxelGeometryBuilderCacheSpace {
|
|
|
27
25
|
this.offset[0] = x;
|
|
28
26
|
this.offset[1] = y;
|
|
29
27
|
this.offset[2] = z;
|
|
30
|
-
this.lightCache.fill(-1);
|
|
31
28
|
this.foundHash.fill(0);
|
|
32
29
|
this.voxelCache.fill(0);
|
|
33
30
|
this.modCache.fill(-1);
|
|
@@ -60,32 +57,12 @@ export class VoxelGeometryBuilderCacheSpace {
|
|
|
60
57
|
}
|
|
61
58
|
return hashed;
|
|
62
59
|
}
|
|
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
60
|
hashState(dataCursor, index, x, y, z) {
|
|
78
61
|
if (this.foundHash[index] == 1)
|
|
79
62
|
return -1;
|
|
80
63
|
if (this.foundHash[index] == 2)
|
|
81
64
|
return this.stateCache[index];
|
|
82
65
|
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
|
-
}
|
|
89
66
|
if (!voxel || !voxel.isRenderable()) {
|
|
90
67
|
this.foundHash[index] = 1;
|
|
91
68
|
return -1;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { MesherDataTool } from "../Geomtry/Tools/MesherDataTools";
|
|
2
1
|
import { QuadScalarVertexData } from "../Geomtry/Primitives/QuadVertexData";
|
|
3
2
|
import { VoxelFaces } from "../../Math";
|
|
4
3
|
import { QuadVerticies } from "../Geomtry/Geometry.types";
|
|
5
4
|
import { VoxelMesh } from "../Geomtry/VoxelMesh";
|
|
6
|
-
import { VoxelMeshBVHBuilder } from "
|
|
5
|
+
import { VoxelMeshBVHBuilder } from "../Geomtry/VoxelMeshBVHBuilder";
|
|
7
6
|
import { Vec3Array, Vector3Like, Vector4Like } from "@amodx/math";
|
|
8
7
|
import { VoxelCursorInterface } from "../../Voxels/Cursor/VoxelCursor.interface.js";
|
|
9
|
-
import { DataCursorInterface } from "../../
|
|
10
|
-
import { VoxelGeometryBuilderCacheSpace } from "
|
|
8
|
+
import { DataCursorInterface } from "../../Voxels/Cursor/DataCursor.interface.js";
|
|
9
|
+
import { VoxelGeometryBuilderCacheSpace } from "./VoxelGeometryBuilderCacheSpace";
|
|
11
10
|
declare class VoxelVars {
|
|
12
11
|
faceFlipped: boolean;
|
|
13
12
|
textureIndex: number;
|
|
@@ -18,7 +17,7 @@ declare class VoxelVars {
|
|
|
18
17
|
level: QuadScalarVertexData;
|
|
19
18
|
reset(): void;
|
|
20
19
|
}
|
|
21
|
-
export declare class
|
|
20
|
+
export declare class VoxelModelBuilder {
|
|
22
21
|
id: string;
|
|
23
22
|
materialIndex: number;
|
|
24
23
|
space: VoxelGeometryBuilderCacheSpace;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
//tools
|
|
2
|
-
import { MesherDataTool } from "../Geomtry/Tools/MesherDataTools";
|
|
3
2
|
//data
|
|
4
3
|
import { QuadScalarVertexData } from "../Geomtry/Primitives/QuadVertexData";
|
|
5
4
|
import { VoxelFaces, VoxelFacesArray } from "../../Math";
|
|
6
5
|
import { QuadVerticies } from "../Geomtry/Geometry.types";
|
|
7
|
-
import calculateFaceData from "
|
|
6
|
+
import calculateFaceData from "./Common/Calc/FaceDataCalc.js";
|
|
8
7
|
import { VoxelMesh } from "../Geomtry/VoxelMesh";
|
|
9
8
|
import { Vector3Like, Vector4Like } from "@amodx/math";
|
|
10
9
|
class VoxelVars {
|
|
@@ -23,7 +22,7 @@ class VoxelVars {
|
|
|
23
22
|
this.overlayTextures.z = 0;
|
|
24
23
|
}
|
|
25
24
|
}
|
|
26
|
-
export class
|
|
25
|
+
export class VoxelModelBuilder {
|
|
27
26
|
id;
|
|
28
27
|
materialIndex;
|
|
29
28
|
space;
|
|
@@ -41,11 +40,10 @@ export class VoxelMesherDataTool extends MesherDataTool {
|
|
|
41
40
|
lightData;
|
|
42
41
|
effects;
|
|
43
42
|
constructor(id, materialIndex) {
|
|
44
|
-
super();
|
|
45
|
-
this.id = id;
|
|
46
|
-
this.materialIndex = materialIndex;
|
|
47
43
|
// this.faceDataOverride.currentVoxel = this.voxel;
|
|
48
44
|
// this.faceDataOverride.neighborVoxel = this.nVoxel;
|
|
45
|
+
this.id = id;
|
|
46
|
+
this.materialIndex = materialIndex;
|
|
49
47
|
this.dataCalculated = [];
|
|
50
48
|
for (const face of VoxelFacesArray) {
|
|
51
49
|
this.dataCalculated[face] = false;
|
|
@@ -74,7 +72,6 @@ export class VoxelMesherDataTool extends MesherDataTool {
|
|
|
74
72
|
this.lightData[face][QuadVerticies.BottomLeft] = 0;
|
|
75
73
|
this.lightData[face][QuadVerticies.BottomRight] = 0;
|
|
76
74
|
}
|
|
77
|
-
this.startNewMesh(new VoxelMesh());
|
|
78
75
|
}
|
|
79
76
|
bounds = {
|
|
80
77
|
min: [0, 0, 0],
|
|
@@ -97,6 +94,13 @@ export class VoxelMesherDataTool extends MesherDataTool {
|
|
|
97
94
|
if (!this._boundsUpdate)
|
|
98
95
|
return false;
|
|
99
96
|
this.bvhTool.updateVoxel(this.position.x, this.position.y, this.position.z, this._indexStart, this.materialIndex, this.mesh.indicieCount, this.bounds.min[0], this.bounds.min[1], this.bounds.min[2], this.bounds.max[0], this.bounds.max[1], this.bounds.max[2]);
|
|
97
|
+
this.bvhTool.structCursor.setIndex(0);
|
|
98
|
+
this.mesh.minBounds.x = this.bvhTool.structCursor.minX;
|
|
99
|
+
this.mesh.minBounds.y = this.bvhTool.structCursor.minY;
|
|
100
|
+
this.mesh.minBounds.z = this.bvhTool.structCursor.minZ;
|
|
101
|
+
this.mesh.maxBounds.x = this.bvhTool.structCursor.maxX;
|
|
102
|
+
this.mesh.maxBounds.y = this.bvhTool.structCursor.maxY;
|
|
103
|
+
this.mesh.maxBounds.z = this.bvhTool.structCursor.maxZ;
|
|
100
104
|
}
|
|
101
105
|
return true;
|
|
102
106
|
}
|