@divinevoxel/vlox 0.0.80 → 0.0.81
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/Builder/Tools/Brush/BrushTool.d.ts +12 -2
- package/Builder/Tools/Brush/BrushTool.js +53 -28
- package/Builder/Tools/Debug/DebugTool.d.ts +18 -0
- package/Builder/Tools/Debug/DebugTool.js +36 -0
- package/Builder/Tools/Path/PahtTool.d.ts +1 -1
- package/Builder/Tools/Path/PahtTool.js +1 -1
- package/Builder/Tools/Sculpt/SculptTool.js +8 -0
- package/Builder/Tools/Wrench/WrenchTool.js +10 -23
- package/Builder/Util/SurfaceBoxSelection.js +2 -0
- package/Builder/VoxelBuildSpace.js +3 -3
- package/Contexts/Base/Remote/InitDataSync.js +1 -1
- package/Math/UtilFunctions.js +7 -8
- package/Math/VoxelFaces.d.ts +2 -2
- package/Math/VoxelFaces.js +46 -55
- package/Math/WorldIndexing.d.ts +11 -0
- package/Math/WorldIndexing.js +34 -0
- package/Mesher/Geometry/Geometry.types.d.ts +2 -2
- package/Mesher/Geometry/Geometry.types.js +7 -20
- package/Mesher/Geometry/Primitives/QuadVertexData.js +118 -119
- package/Mesher/Geometry/Primitives/TriangleVertexData.js +89 -90
- package/Mesher/Geometry/Proto/ProtoMesh.d.ts +1 -1
- package/Mesher/Geometry/Proto/ProtoMesh.js +22 -29
- package/Mesher/Geometry/Proto/ProtoMeshBuffer.d.ts +4 -2
- package/Mesher/Geometry/Proto/ProtoMeshBuffer.js +14 -6
- package/Mesher/Geometry/Shapes/Box.js +6 -7
- package/Mesher/Geometry/Transform/TransformBox.js +8 -9
- package/Mesher/Geometry/Transform/TransformQuad.js +4 -5
- package/Mesher/Geometry/Transform/TransformTriangle.js +3 -4
- package/Mesher/InitMesher.js +4 -9
- package/Mesher/Items/Geometry/ItemGeometryBuilder.js +7 -8
- package/Mesher/Items/MeshTexture.js +125 -57
- package/Mesher/Voxels/Base/BuildVoxel.d.ts +6 -0
- package/Mesher/Voxels/Base/BuildVoxel.js +101 -0
- package/Mesher/Voxels/Base/CompactVoxelSectionMesh.js +1 -21
- package/Mesher/Voxels/Base/MeshSectionBase.js +3 -26
- package/Mesher/Voxels/Geometry/VoxelGeometryBuilder.js +33 -31
- package/Mesher/Voxels/Geometry/VoxelShaderData.js +3 -7
- package/Mesher/Voxels/MeshTemplate.js +6 -26
- package/Mesher/Voxels/MeshVoxel.js +5 -10
- package/Mesher/Voxels/Models/Common/Calc/CalcConstants.js +41 -42
- package/Mesher/Voxels/Models/Common/Calc/FaceDataCalc.js +6 -9
- package/Mesher/Voxels/Models/Common/Faces/CullRulledFace.js +64 -47
- package/Mesher/Voxels/Models/Common/Faces/ShadeRulledFace.js +57 -43
- package/Mesher/Voxels/Models/Nodes/Custom/Liquid/FlowGradient.js +4 -5
- package/Mesher/Voxels/Models/Nodes/Custom/Liquid/LiquidGeometryNode.d.ts +1 -1
- package/Mesher/Voxels/Models/Nodes/Custom/Liquid/LiquidGeometryNode.js +116 -118
- package/Mesher/Voxels/Models/Nodes/Default/QuadVoxelGeometryNode.js +4 -4
- package/Mesher/Voxels/Models/Nodes/VoxelGeometryConstructor.js +2 -2
- package/Mesher/Voxels/Models/Procedures/Default/OutlinedTextureProcedure.js +19 -21
- package/Mesher/Voxels/Models/Procedures/Default/PillarTextureProcedure.js +45 -38
- package/Mesher/Voxels/Models/RenderedMaterials.d.ts +1 -1
- package/Mesher/Voxels/Models/RenderedMaterials.js +8 -5
- package/Mesher/Voxels/Models/VoxelGeometryBuilderCacheSpace.d.ts +18 -4
- package/Mesher/Voxels/Models/VoxelGeometryBuilderCacheSpace.js +135 -22
- package/Mesher/Voxels/Models/VoxelGeometryBuilderCacheSpaceN.d.ts +33 -0
- package/Mesher/Voxels/Models/VoxelGeometryBuilderCacheSpaceN.js +204 -0
- package/Mesher/Voxels/Models/{VoxelModelConstructorRegister.d.ts → VoxelGeometryConstructorRegister.d.ts} +1 -6
- package/Mesher/Voxels/Models/VoxelGeometryConstructorRegister.js +20 -0
- package/Mesher/Voxels/Models/VoxelModelBuilder.js +15 -16
- package/Mesher/Voxels/Models/VoxelModelEffect.d.ts +1 -3
- package/Mesher/Voxels/Models/VoxelModelEffect.js +1 -3
- package/Renderer/DVERenderNode.types.d.ts +1 -0
- package/Renderer/InitTasks.js +2 -0
- package/Tasks/Paint/Erase/EraseVoxel.js +1 -1
- package/Tasks/Propagation/Illumanation/RGBUpdate.js +191 -48
- package/Tasks/Propagation/Illumanation/SunUpdate.d.ts +1 -1
- package/Tasks/Propagation/Illumanation/SunUpdate.js +167 -63
- package/Tasks/Propagation/Illumanation/WorldSun.js +96 -60
- package/Tasks/WorldGeneration/WorldGenBrush.d.ts +2 -0
- package/Tasks/WorldGeneration/WorldGenBrush.js +31 -0
- package/Templates/Archive/ArchivedVoxelTemplate.js +1 -1
- package/Templates/Archive/Functions/CreateArchivedTemplate.js +1 -1
- package/Templates/Archive/Functions/CreateArchivedTemplateFromFull.d.ts +6 -0
- package/Templates/Archive/Functions/CreateArchivedTemplateFromFull.js +174 -0
- package/Textures/Classes/CompactedTextureReader.d.ts +22 -0
- package/Textures/Classes/CompactedTextureReader.js +90 -0
- package/Textures/Classes/CompiledTexture.d.ts +4 -1
- package/Textures/Classes/CompiledTexture.js +36 -8
- package/Textures/Classes/TextureAtlasIndex.d.ts +7 -0
- package/Textures/Classes/TextureAtlasIndex.js +14 -0
- package/Textures/Classes/TextureLoader.d.ts +20 -0
- package/Textures/Classes/TextureLoader.js +95 -0
- package/Textures/Functions/BuildTextureData.d.ts +1 -1
- package/Textures/Functions/BuildTextureData.js +19 -122
- package/Textures/Functions/CreateCompactedTexture.d.ts +6 -0
- package/Textures/Functions/CreateCompactedTexture.js +105 -0
- package/Textures/Functions/ReadCompactedTexture.d.ts +2 -0
- package/Textures/Functions/ReadCompactedTexture.js +42 -0
- package/Textures/Texture.types.d.ts +14 -0
- package/Textures/TextureManager.d.ts +7 -1
- package/Textures/TextureManager.js +13 -0
- package/Tools/Brush/Brush.d.ts +4 -2
- package/Tools/Brush/Brush.js +28 -6
- package/Util/BinaryBuffer/Functions/BinaryBufferConvert.d.ts +1 -1
- package/Util/TickInterval.d.ts +3 -0
- package/Util/TickInterval.js +31 -3
- package/Voxels/Archive/VoxelPaletteArchiveReader.d.ts +1 -0
- package/Voxels/Archive/VoxelPaletteArchiveReader.js +9 -10
- package/Voxels/Archive/VoxelPaletteArechive.js +5 -4
- package/Voxels/Cursor/VoxelCursor.interface.d.ts +1 -1
- package/Voxels/Cursor/VoxelCursor.interface.js +22 -16
- package/Voxels/Data/VoxelLUT.d.ts +69 -42
- package/Voxels/Data/VoxelLUT.js +110 -53
- package/Voxels/Functions/BuildLUTs.js +100 -45
- package/Voxels/Functions/Geometry/CalcFunctions.js +6 -7
- package/Voxels/Functions/Geometry/Inputs/BuildTriangleInputs.js +3 -0
- package/Voxels/Indexes/VoxelIndex.js +3 -1
- package/Voxels/InitVoxelData.js +3 -1
- package/Voxels/Interaction/Functions/PickVoxel.js +3 -5
- package/Voxels/Interaction/Functions/PickVoxelWorld.js +4 -6
- package/Voxels/Models/Defaults/Examples.d.ts +2 -0
- package/Voxels/Models/Defaults/Examples.js +151 -2
- package/Voxels/State/Reltional/ReltionalStateBuilder.js +2 -0
- package/Voxels/State/Schema/BinarySchema.d.ts +1 -0
- package/Voxels/State/Schema/BinarySchema.js +14 -0
- package/Voxels/State/VoxelSchemas.d.ts +11 -4
- package/Voxels/State/VoxelSchemas.js +42 -9
- package/Voxels/Types/PaintVoxelData.js +6 -2
- package/World/Archive/Classes/ImportedSection.js +1 -1
- package/World/Archive/Classes/ImportedSector.js +0 -1
- package/World/Archive/Functions/Sector/ArchiveSector.js +2 -2
- package/World/Archive/Functions/Sector/ImportSector.d.ts +1 -0
- package/World/Archive/Functions/Sector/ImportSector.js +183 -7
- package/World/Cursor/SectorCursor.js +1 -4
- package/World/Cursor/WorldCursor.d.ts +12 -3
- package/World/Cursor/WorldCursor.js +60 -30
- package/World/InitTasks.js +1 -1
- package/World/Lock/Function/LockSectors.js +5 -1
- package/World/Lock/Function/UnLockSectors.js +5 -1
- package/World/SnapShot/SectionSnapShot.d.ts +7 -3
- package/World/SnapShot/SectionSnapShot.js +47 -21
- package/World/SnapShot/SectionSnapShotCursor.d.ts +4 -2
- package/World/SnapShot/SectionSnapShotCursor.js +23 -11
- package/World/SnapShot/SnapShots.d.ts +1 -2
- package/World/SnapShot/SnapShots.js +3 -3
- package/World/WorldSpaces.d.ts +7 -0
- package/World/WorldSpaces.js +35 -13
- package/WorldSimulation/Dimensions/DimensionSegment.d.ts +2 -0
- package/WorldSimulation/Dimensions/DimensionSegment.js +9 -1
- package/WorldSimulation/Dimensions/DimensionSimulation.js +6 -7
- package/WorldSimulation/Dimensions/Generator.d.ts +4 -0
- package/WorldSimulation/Dimensions/Generator.js +15 -1
- package/WorldSimulation/Dimensions/SimulationSector.d.ts +1 -0
- package/WorldSimulation/Dimensions/SimulationSector.js +18 -0
- package/WorldSimulation/Internal/WorldSimulationTasks.js +11 -7
- package/WorldSimulation/Procedures/InitalLoad.d.ts +1 -0
- package/WorldSimulation/Procedures/InitalLoad.js +18 -8
- package/WorldSimulation/Tasks/SimulationTaskBase.d.ts +4 -1
- package/WorldSimulation/Tasks/SimulationTaskBase.js +13 -2
- package/WorldSimulation/Tasks/TaskSegment.d.ts +4 -2
- package/WorldSimulation/Tasks/TaskSegment.js +36 -22
- package/WorldSimulation/Voxels/Ticks/Types/LiquidVoxelUpdate.js +1 -2
- package/WorldSimulation/WorldSimulation.d.ts +6 -3
- package/WorldSimulation/WorldSimulation.js +44 -20
- package/package.json +1 -1
- package/Mesher/Items/MeshTextureO.d.ts +0 -1
- package/Mesher/Items/MeshTextureO.js +0 -277
- package/Mesher/Voxels/Models/VoxelConstructor.d.ts +0 -8
- package/Mesher/Voxels/Models/VoxelConstructor.js +0 -78
- package/Mesher/Voxels/Models/VoxelModelConstructorRegister.js +0 -37
- package/WorldSimulation/Procedures/BuildOnly.d.ts +0 -10
- package/WorldSimulation/Procedures/BuildOnly.js +0 -55
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TextureProcedure, } from "../TextureProcedure";
|
|
2
|
-
import { VoxelFaceDirections
|
|
2
|
+
import { VoxelFaceDirections } from "../../../../../Math/index.js";
|
|
3
3
|
const textureMap = [
|
|
4
4
|
"top",
|
|
5
5
|
"corner-top-right",
|
|
@@ -58,7 +58,7 @@ const uvsSets = {
|
|
|
58
58
|
},
|
|
59
59
|
};
|
|
60
60
|
const CheckSets = {
|
|
61
|
-
[VoxelFaces.Up]: {
|
|
61
|
+
[0 /* VoxelFaces.Up */]: {
|
|
62
62
|
north: [
|
|
63
63
|
[0, 0, 1],
|
|
64
64
|
[1, 0, 1],
|
|
@@ -72,35 +72,35 @@ const CheckSets = {
|
|
|
72
72
|
east: [[1, 0, 0]],
|
|
73
73
|
west: [[-1, 0, 0]],
|
|
74
74
|
},
|
|
75
|
-
[VoxelFaces.Down]: {
|
|
75
|
+
[1 /* VoxelFaces.Down */]: {
|
|
76
76
|
north: [
|
|
77
77
|
[0, 0, 1],
|
|
78
|
-
[1, 0, 1],
|
|
79
78
|
[-1, 0, 1],
|
|
79
|
+
[1, 0, 1],
|
|
80
80
|
],
|
|
81
81
|
south: [
|
|
82
82
|
[0, 0, -1],
|
|
83
|
-
[1, 0, -1],
|
|
84
83
|
[-1, 0, -1],
|
|
84
|
+
[1, 0, -1],
|
|
85
85
|
],
|
|
86
86
|
east: [[-1, 0, 0]],
|
|
87
87
|
west: [[1, 0, 0]],
|
|
88
88
|
},
|
|
89
|
-
[VoxelFaces.North]: {
|
|
89
|
+
[2 /* VoxelFaces.North */]: {
|
|
90
90
|
north: [
|
|
91
91
|
[0, 1, 0],
|
|
92
|
-
[1, 1, 0],
|
|
93
92
|
[-1, 1, 0],
|
|
93
|
+
[1, 1, 0],
|
|
94
94
|
],
|
|
95
95
|
south: [
|
|
96
96
|
[0, -1, 0],
|
|
97
|
-
[1, -1, 0],
|
|
98
97
|
[-1, -1, 0],
|
|
98
|
+
[1, -1, 0],
|
|
99
99
|
],
|
|
100
100
|
east: [[-1, 0, 0]],
|
|
101
101
|
west: [[1, 0, 0]],
|
|
102
102
|
},
|
|
103
|
-
[VoxelFaces.South]: {
|
|
103
|
+
[3 /* VoxelFaces.South */]: {
|
|
104
104
|
north: [
|
|
105
105
|
[0, 1, 0],
|
|
106
106
|
[1, 1, 0],
|
|
@@ -114,7 +114,7 @@ const CheckSets = {
|
|
|
114
114
|
east: [[1, 0, 0]],
|
|
115
115
|
west: [[-1, 0, 0]],
|
|
116
116
|
},
|
|
117
|
-
[VoxelFaces.East]: {
|
|
117
|
+
[4 /* VoxelFaces.East */]: {
|
|
118
118
|
north: [
|
|
119
119
|
[0, 1, 0],
|
|
120
120
|
[0, 1, 1],
|
|
@@ -128,16 +128,16 @@ const CheckSets = {
|
|
|
128
128
|
east: [[0, 0, 1]],
|
|
129
129
|
west: [[0, 0, -1]],
|
|
130
130
|
},
|
|
131
|
-
[VoxelFaces.West]: {
|
|
131
|
+
[5 /* VoxelFaces.West */]: {
|
|
132
132
|
north: [
|
|
133
133
|
[0, 1, 0],
|
|
134
|
-
[0, 1, 1],
|
|
135
134
|
[0, 1, -1],
|
|
135
|
+
[0, 1, 1],
|
|
136
136
|
],
|
|
137
137
|
south: [
|
|
138
138
|
[0, -1, 0],
|
|
139
|
-
[0, -1, 1],
|
|
140
139
|
[0, -1, -1],
|
|
140
|
+
[0, -1, 1],
|
|
141
141
|
],
|
|
142
142
|
east: [[0, 0, -1]],
|
|
143
143
|
west: [[0, 0, 1]],
|
|
@@ -146,17 +146,17 @@ const CheckSets = {
|
|
|
146
146
|
const generateCheck = (direction, tool, normal, sets) => {
|
|
147
147
|
const { x, y, z } = tool.position;
|
|
148
148
|
let key = 0b0;
|
|
149
|
+
const currentVoxelId = tool.voxel.getVoxelId();
|
|
149
150
|
for (let i = 0; i < sets.length; i++) {
|
|
150
151
|
const set = sets[i];
|
|
151
152
|
const cx = x + set[0];
|
|
152
153
|
const cy = y + set[1];
|
|
153
154
|
const cz = z + set[2];
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
?.isSameVoxel(tool.voxel);
|
|
155
|
+
const hashed = tool.space.getHash(tool.nVoxel, cx, cy, cz);
|
|
156
|
+
const sameLevelCheck = currentVoxelId == tool.space.getTrueVoxelId(hashed);
|
|
157
157
|
let normalCheck = true;
|
|
158
|
-
const
|
|
159
|
-
if (
|
|
158
|
+
const hashedNormal = tool.space.getHash(tool.nVoxel, cx + normal[0], cy + normal[1], cz + normal[2]);
|
|
159
|
+
if (tool.space.foundHash[hashedNormal] == 2) {
|
|
160
160
|
normalCheck = false;
|
|
161
161
|
}
|
|
162
162
|
if (sameLevelCheck && normalCheck) {
|
|
@@ -180,9 +180,7 @@ export class OutlinedTextureProcedure extends TextureProcedure {
|
|
|
180
180
|
getOverlayTexture(builder, data, closestFace, primitive, ref) {
|
|
181
181
|
const set = CheckSets[closestFace];
|
|
182
182
|
const normal = VoxelFaceDirections[closestFace];
|
|
183
|
-
const isTopOrBottom = closestFace === VoxelFaces.Up || closestFace === VoxelFaces.Down
|
|
184
|
-
// For top/bottom faces, use north/south/east/west sets.
|
|
185
|
-
// For side faces (north/south/east/west), use top/bottom/right/left sets.
|
|
183
|
+
const isTopOrBottom = closestFace === 0 /* VoxelFaces.Up */ || closestFace === 1 /* VoxelFaces.Down */;
|
|
186
184
|
const dirNorth = isTopOrBottom ? "north" : "top";
|
|
187
185
|
const dirSouth = isTopOrBottom ? "south" : "bottom";
|
|
188
186
|
const dirEast = isTopOrBottom ? "east" : "right";
|
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
import { TextureProcedure, } from "../TextureProcedure";
|
|
2
|
-
import { VoxelFaces } from "../../../../../Math";
|
|
3
2
|
import { VoxelLUT } from "../../../../../Voxels/Data/VoxelLUT";
|
|
4
3
|
export class PillarTextureProcedure extends TextureProcedure {
|
|
5
4
|
getTexture(builder, data, closestFace, primitive) {
|
|
6
5
|
if (data.direction == "up-down") {
|
|
7
|
-
if (closestFace == VoxelFaces.Up)
|
|
6
|
+
if (closestFace == 0 /* VoxelFaces.Up */)
|
|
8
7
|
return data.textureRecrod.upTex;
|
|
9
|
-
if (closestFace == VoxelFaces.Down)
|
|
8
|
+
if (closestFace == 1 /* VoxelFaces.Down */)
|
|
10
9
|
return data.textureRecrod.downTex;
|
|
11
10
|
let sideTexture = data.textureRecrod.sideDisconnectedTex;
|
|
12
|
-
const currentState = VoxelLUT.
|
|
11
|
+
const currentState = VoxelLUT.voxelIdToState[builder.voxel.getId()];
|
|
13
12
|
const topVoxel = builder.nVoxel.getVoxel(builder.position.x, builder.position.y + 1, builder.position.z);
|
|
14
13
|
const topSame = topVoxel
|
|
15
14
|
? builder.voxel.isSameVoxel(topVoxel) &&
|
|
16
|
-
VoxelLUT.
|
|
15
|
+
VoxelLUT.voxelIdToState[topVoxel.getId()] == currentState
|
|
17
16
|
: false;
|
|
18
17
|
const bottomVoxel = builder.nVoxel.getVoxel(builder.position.x, builder.position.y - 1, builder.position.z);
|
|
19
18
|
const bottomSame = bottomVoxel
|
|
20
19
|
? builder.voxel.isSameVoxel(bottomVoxel) &&
|
|
21
|
-
VoxelLUT.
|
|
20
|
+
VoxelLUT.voxelIdToState[bottomVoxel.getId()] == currentState
|
|
22
21
|
: false;
|
|
23
22
|
if (topSame && !bottomSame) {
|
|
24
23
|
sideTexture = data.textureRecrod.sideDownTex;
|
|
@@ -29,28 +28,28 @@ export class PillarTextureProcedure extends TextureProcedure {
|
|
|
29
28
|
if (topSame && bottomSame) {
|
|
30
29
|
sideTexture = data.textureRecrod.sideConnectedTex;
|
|
31
30
|
}
|
|
32
|
-
if (closestFace == VoxelFaces.North ||
|
|
33
|
-
closestFace == VoxelFaces.South ||
|
|
34
|
-
closestFace == VoxelFaces.East ||
|
|
35
|
-
closestFace == VoxelFaces.West)
|
|
31
|
+
if (closestFace == 2 /* VoxelFaces.North */ ||
|
|
32
|
+
closestFace == 3 /* VoxelFaces.South */ ||
|
|
33
|
+
closestFace == 4 /* VoxelFaces.East */ ||
|
|
34
|
+
closestFace == 5 /* VoxelFaces.West */)
|
|
36
35
|
return sideTexture;
|
|
37
36
|
}
|
|
38
37
|
if (data.direction == "north-south") {
|
|
39
|
-
if (closestFace == VoxelFaces.North)
|
|
38
|
+
if (closestFace == 2 /* VoxelFaces.North */)
|
|
40
39
|
return data.textureRecrod.upTex;
|
|
41
|
-
if (closestFace == VoxelFaces.South)
|
|
40
|
+
if (closestFace == 3 /* VoxelFaces.South */)
|
|
42
41
|
return data.textureRecrod.downTex;
|
|
43
42
|
let sideTexture = data.textureRecrod.sideDisconnectedTex;
|
|
44
|
-
const currentState = VoxelLUT.
|
|
43
|
+
const currentState = VoxelLUT.voxelIdToState[builder.voxel.getId()];
|
|
45
44
|
const northVoxel = builder.nVoxel.getVoxel(builder.position.x, builder.position.y, builder.position.z + 1);
|
|
46
45
|
const northSame = northVoxel
|
|
47
46
|
? builder.voxel.isSameVoxel(northVoxel) &&
|
|
48
|
-
VoxelLUT.
|
|
47
|
+
VoxelLUT.voxelIdToState[northVoxel.getId()] == currentState
|
|
49
48
|
: false;
|
|
50
49
|
const southVoxel = builder.nVoxel.getVoxel(builder.position.x, builder.position.y, builder.position.z - 1);
|
|
51
50
|
const southSame = southVoxel
|
|
52
51
|
? builder.voxel.isSameVoxel(southVoxel) &&
|
|
53
|
-
VoxelLUT.
|
|
52
|
+
VoxelLUT.voxelIdToState[southVoxel.getId()] == currentState
|
|
54
53
|
: false;
|
|
55
54
|
if (northSame && !southSame) {
|
|
56
55
|
sideTexture = data.textureRecrod.sideDownTex;
|
|
@@ -61,42 +60,42 @@ export class PillarTextureProcedure extends TextureProcedure {
|
|
|
61
60
|
if (northSame && southSame) {
|
|
62
61
|
sideTexture = data.textureRecrod.sideConnectedTex;
|
|
63
62
|
}
|
|
64
|
-
if (closestFace == VoxelFaces.Up ||
|
|
65
|
-
closestFace == VoxelFaces.Down ||
|
|
66
|
-
closestFace == VoxelFaces.East ||
|
|
67
|
-
closestFace == VoxelFaces.West)
|
|
63
|
+
if (closestFace == 0 /* VoxelFaces.Up */ ||
|
|
64
|
+
closestFace == 1 /* VoxelFaces.Down */ ||
|
|
65
|
+
closestFace == 4 /* VoxelFaces.East */ ||
|
|
66
|
+
closestFace == 5 /* VoxelFaces.West */)
|
|
68
67
|
return sideTexture;
|
|
69
68
|
}
|
|
70
69
|
if (data.direction == "east-west") {
|
|
71
|
-
if (closestFace == VoxelFaces.East)
|
|
70
|
+
if (closestFace == 4 /* VoxelFaces.East */)
|
|
72
71
|
return data.textureRecrod.upTex;
|
|
73
|
-
if (closestFace == VoxelFaces.West)
|
|
72
|
+
if (closestFace == 5 /* VoxelFaces.West */)
|
|
74
73
|
return data.textureRecrod.downTex;
|
|
75
74
|
let sideTexture = data.textureRecrod.sideDisconnectedTex;
|
|
76
|
-
const currentState = VoxelLUT.
|
|
75
|
+
const currentState = VoxelLUT.voxelIdToState[builder.voxel.getId()];
|
|
77
76
|
const eastVoxel = builder.nVoxel.getVoxel(builder.position.x + 1, builder.position.y, builder.position.z);
|
|
78
|
-
const
|
|
77
|
+
const eastSame = eastVoxel
|
|
79
78
|
? builder.voxel.isSameVoxel(eastVoxel) &&
|
|
80
|
-
VoxelLUT.
|
|
79
|
+
VoxelLUT.voxelIdToState[eastVoxel.getId()] == currentState
|
|
81
80
|
: false;
|
|
82
81
|
const westVoxel = builder.nVoxel.getVoxel(builder.position.x - 1, builder.position.y, builder.position.z);
|
|
83
82
|
const westSame = westVoxel
|
|
84
83
|
? builder.voxel.isSameVoxel(westVoxel) &&
|
|
85
|
-
VoxelLUT.
|
|
84
|
+
VoxelLUT.voxelIdToState[westVoxel.getId()] == currentState
|
|
86
85
|
: false;
|
|
87
|
-
if (
|
|
86
|
+
if (eastSame && !westSame) {
|
|
88
87
|
sideTexture = data.textureRecrod.sideDownTex;
|
|
89
88
|
}
|
|
90
|
-
if (!
|
|
89
|
+
if (!eastSame && westSame) {
|
|
91
90
|
sideTexture = data.textureRecrod.sideUpTex;
|
|
92
91
|
}
|
|
93
|
-
if (
|
|
92
|
+
if (eastSame && westSame) {
|
|
94
93
|
sideTexture = data.textureRecrod.sideConnectedTex;
|
|
95
94
|
}
|
|
96
|
-
if (closestFace == VoxelFaces.Up ||
|
|
97
|
-
closestFace == VoxelFaces.Down ||
|
|
98
|
-
closestFace == VoxelFaces.North ||
|
|
99
|
-
closestFace == VoxelFaces.South)
|
|
95
|
+
if (closestFace == 0 /* VoxelFaces.Up */ ||
|
|
96
|
+
closestFace == 1 /* VoxelFaces.Down */ ||
|
|
97
|
+
closestFace == 2 /* VoxelFaces.North */ ||
|
|
98
|
+
closestFace == 3 /* VoxelFaces.South */)
|
|
100
99
|
return sideTexture;
|
|
101
100
|
}
|
|
102
101
|
throw new Error(`Invalid direction for pillar box texture procedure | ${data.direction}`);
|
|
@@ -105,13 +104,13 @@ export class PillarTextureProcedure extends TextureProcedure {
|
|
|
105
104
|
return ref;
|
|
106
105
|
}
|
|
107
106
|
transformUVs(builder, data, closestFace, primitive) {
|
|
108
|
-
|
|
109
|
-
(closestFace == VoxelFaces.East || closestFace == VoxelFaces.West)) ||
|
|
107
|
+
const rotate90 = (data.direction == "north-south" && closestFace == 4 /* VoxelFaces.East */) ||
|
|
110
108
|
(data.direction == "east-west" &&
|
|
111
|
-
(closestFace == VoxelFaces.
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
109
|
+
(closestFace == 3 /* VoxelFaces.South */ || closestFace == 0 /* VoxelFaces.Up */));
|
|
110
|
+
const rotate270 = (data.direction == "north-south" && closestFace == 5 /* VoxelFaces.West */) ||
|
|
111
|
+
(data.direction == "east-west" &&
|
|
112
|
+
(closestFace == 2 /* VoxelFaces.North */ || closestFace == 1 /* VoxelFaces.Down */));
|
|
113
|
+
if (rotate90) {
|
|
115
114
|
for (const v of primitive.uvs.vertices) {
|
|
116
115
|
const oldX = v.x;
|
|
117
116
|
const oldY = v.y;
|
|
@@ -119,5 +118,13 @@ export class PillarTextureProcedure extends TextureProcedure {
|
|
|
119
118
|
v.y = oldX;
|
|
120
119
|
}
|
|
121
120
|
}
|
|
121
|
+
else if (rotate270) {
|
|
122
|
+
for (const v of primitive.uvs.vertices) {
|
|
123
|
+
const oldX = v.x;
|
|
124
|
+
const oldY = v.y;
|
|
125
|
+
v.x = oldY;
|
|
126
|
+
v.y = 1 - oldX;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
122
129
|
}
|
|
123
130
|
}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
import { VoxelLUT } from "../../../Voxels/Data/VoxelLUT";
|
|
1
2
|
import { VoxelModelBuilder } from "./VoxelModelBuilder";
|
|
2
3
|
export class RenderedMaterials {
|
|
3
4
|
static meshersMap = new Map();
|
|
4
5
|
static meshers = [];
|
|
5
|
-
static
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
static init() {
|
|
7
|
+
const materials = VoxelLUT.material._palette;
|
|
8
|
+
for (const mat of materials) {
|
|
9
|
+
const index = VoxelLUT.material.getNumberId(mat);
|
|
10
|
+
const newTool = new VoxelModelBuilder(mat, index);
|
|
11
|
+
this.meshersMap.set(mat, newTool);
|
|
12
|
+
this.meshers[index] = newTool;
|
|
10
13
|
}
|
|
11
14
|
}
|
|
12
15
|
}
|
|
@@ -4,16 +4,30 @@ import { VoxelCursor } from "../../../Voxels/Cursor/VoxelCursor";
|
|
|
4
4
|
export declare class VoxelGeometryBuilderCacheSpace {
|
|
5
5
|
bounds: Vector3Like;
|
|
6
6
|
foundHash: Uint8Array;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
lightCache: Int32Array;
|
|
8
|
+
private voxelCache;
|
|
9
|
+
private trueVoxelCache;
|
|
10
|
+
private reltionalVoxelCache;
|
|
11
|
+
private reltionalStateCache;
|
|
12
|
+
secondaryVoxelCache: Uint16Array;
|
|
13
|
+
secondaryTrueVoxelCache: Uint16Array;
|
|
14
|
+
secondaryReltionalVoxelCache: Uint16Array;
|
|
15
|
+
secondaryReltionalStateCache: Uint16Array;
|
|
16
|
+
hasSecondary: Uint8Array;
|
|
11
17
|
noCastAO: Uint8Array;
|
|
18
|
+
secondaryNoCastAO: Uint8Array;
|
|
19
|
+
fullBlock: Uint8Array;
|
|
12
20
|
offset: Vec3Array;
|
|
13
21
|
voxelCursor: VoxelCursor;
|
|
14
22
|
constructor(bounds: Vector3Like);
|
|
15
23
|
start(x: number, y: number, z: number): void;
|
|
16
24
|
getIndex(x: number, y: number, z: number): number;
|
|
17
25
|
getHash(dataCursor: DataCursorInterface, x: number, y: number, z: number): number;
|
|
26
|
+
getNoCastAO(index: number, secondary?: boolean): boolean;
|
|
27
|
+
getTrueVoxelId(index: number, secondary?: boolean): number;
|
|
28
|
+
getVoxelId(index: number, secondary?: boolean): number;
|
|
29
|
+
getRelationalState(index: number, secondary?: boolean): number;
|
|
30
|
+
getRelationalVoxelId(index: number, secondary?: boolean): number;
|
|
31
|
+
getHasSecondary(index: number): number;
|
|
18
32
|
private hashState;
|
|
19
33
|
}
|
|
@@ -5,6 +5,7 @@ import { VoxelLUT } from "../../../Voxels/Data/VoxelLUT";
|
|
|
5
5
|
export class VoxelGeometryBuilderCacheSpace {
|
|
6
6
|
bounds;
|
|
7
7
|
foundHash;
|
|
8
|
+
lightCache;
|
|
8
9
|
//cache of the voxel ids
|
|
9
10
|
voxelCache;
|
|
10
11
|
//cache of the true voxel ids
|
|
@@ -13,29 +14,56 @@ export class VoxelGeometryBuilderCacheSpace {
|
|
|
13
14
|
reltionalVoxelCache;
|
|
14
15
|
//cache of the reltional state
|
|
15
16
|
reltionalStateCache;
|
|
17
|
+
//cache of the secondary voxel ids
|
|
18
|
+
secondaryVoxelCache;
|
|
19
|
+
//cache of the true secondary voxel ids
|
|
20
|
+
secondaryTrueVoxelCache;
|
|
21
|
+
//cache of the reltional secondary voxel ids
|
|
22
|
+
secondaryReltionalVoxelCache;
|
|
23
|
+
//cache of the secondary reltional state
|
|
24
|
+
secondaryReltionalStateCache;
|
|
25
|
+
hasSecondary;
|
|
16
26
|
noCastAO;
|
|
27
|
+
secondaryNoCastAO;
|
|
28
|
+
fullBlock;
|
|
17
29
|
offset = [0, 0, 0];
|
|
18
30
|
voxelCursor = new VoxelCursor();
|
|
19
31
|
constructor(bounds) {
|
|
20
32
|
this.bounds = bounds;
|
|
21
33
|
const volume = bounds.x * bounds.y * bounds.z;
|
|
22
34
|
this.foundHash = new Uint8Array(volume);
|
|
35
|
+
this.lightCache = new Int32Array(volume);
|
|
23
36
|
this.voxelCache = new Uint16Array(volume);
|
|
24
37
|
this.trueVoxelCache = new Uint16Array(volume);
|
|
25
38
|
this.reltionalVoxelCache = new Uint16Array(volume);
|
|
26
39
|
this.reltionalStateCache = new Uint16Array(volume);
|
|
40
|
+
this.secondaryVoxelCache = new Uint16Array(volume);
|
|
41
|
+
this.secondaryTrueVoxelCache = new Uint16Array(volume);
|
|
42
|
+
this.secondaryReltionalVoxelCache = new Uint16Array(volume);
|
|
43
|
+
this.secondaryReltionalStateCache = new Uint16Array(volume);
|
|
44
|
+
this.fullBlock = new Uint8Array(volume);
|
|
45
|
+
this.hasSecondary = new Uint8Array(volume);
|
|
27
46
|
this.noCastAO = new Uint8Array(volume);
|
|
47
|
+
this.secondaryNoCastAO = new Uint8Array(volume);
|
|
28
48
|
}
|
|
29
49
|
start(x, y, z) {
|
|
30
50
|
this.offset[0] = x;
|
|
31
51
|
this.offset[1] = y;
|
|
32
52
|
this.offset[2] = z;
|
|
53
|
+
this.fullBlock.fill(0);
|
|
54
|
+
this.lightCache.fill(0);
|
|
33
55
|
this.foundHash.fill(0);
|
|
34
56
|
this.voxelCache.fill(0);
|
|
35
57
|
this.trueVoxelCache.fill(0);
|
|
36
58
|
this.reltionalVoxelCache.fill(0);
|
|
37
59
|
this.reltionalStateCache.fill(0);
|
|
60
|
+
this.secondaryVoxelCache.fill(0);
|
|
61
|
+
this.secondaryTrueVoxelCache.fill(0);
|
|
62
|
+
this.secondaryReltionalVoxelCache.fill(0);
|
|
63
|
+
this.secondaryReltionalStateCache.fill(0);
|
|
64
|
+
this.hasSecondary.fill(0);
|
|
38
65
|
this.noCastAO.fill(0);
|
|
66
|
+
this.secondaryNoCastAO.fill(0);
|
|
39
67
|
}
|
|
40
68
|
getIndex(x, y, z) {
|
|
41
69
|
return GetYXZOrderArrayIndex(x - this.offset[0], y - this.offset[1], z - this.offset[2], this.bounds.x, this.bounds.y, this.bounds.z);
|
|
@@ -47,13 +75,46 @@ export class VoxelGeometryBuilderCacheSpace {
|
|
|
47
75
|
}
|
|
48
76
|
return hashed;
|
|
49
77
|
}
|
|
78
|
+
getNoCastAO(index, secondary = false) {
|
|
79
|
+
return ((secondary ? this.secondaryNoCastAO[index] : this.noCastAO[index]) == 1);
|
|
80
|
+
}
|
|
81
|
+
getTrueVoxelId(index, secondary = false) {
|
|
82
|
+
return secondary
|
|
83
|
+
? this.secondaryTrueVoxelCache[index]
|
|
84
|
+
: this.trueVoxelCache[index];
|
|
85
|
+
}
|
|
86
|
+
getVoxelId(index, secondary = false) {
|
|
87
|
+
return secondary ? this.secondaryVoxelCache[index] : this.voxelCache[index];
|
|
88
|
+
}
|
|
89
|
+
getRelationalState(index, secondary = false) {
|
|
90
|
+
return secondary
|
|
91
|
+
? this.secondaryReltionalStateCache[index]
|
|
92
|
+
: this.reltionalStateCache[index];
|
|
93
|
+
}
|
|
94
|
+
getRelationalVoxelId(index, secondary = false) {
|
|
95
|
+
return secondary
|
|
96
|
+
? this.secondaryReltionalVoxelCache[index]
|
|
97
|
+
: this.reltionalVoxelCache[index];
|
|
98
|
+
}
|
|
99
|
+
getHasSecondary(index) {
|
|
100
|
+
return this.hasSecondary[index];
|
|
101
|
+
}
|
|
50
102
|
hashState(dataCursor, index, x, y, z) {
|
|
51
|
-
if (this.foundHash[index]
|
|
52
|
-
return;
|
|
53
|
-
if (this.foundHash[index] == 2)
|
|
103
|
+
if (this.foundHash[index] > 0)
|
|
54
104
|
return;
|
|
55
105
|
const voxel = dataCursor.getVoxel(x, y, z);
|
|
56
|
-
if (
|
|
106
|
+
if (voxel) {
|
|
107
|
+
this.lightCache[index] = voxel.getLight();
|
|
108
|
+
}
|
|
109
|
+
if (!voxel) {
|
|
110
|
+
this.foundHash[index] = 1;
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const canHaveSecondary = voxel.canHaveSecondaryVoxel();
|
|
114
|
+
voxel.setSecondary(true);
|
|
115
|
+
const hasSecondary = canHaveSecondary && voxel.getStringId() !== "dve_air";
|
|
116
|
+
voxel.setSecondary(false);
|
|
117
|
+
if (!voxel.isRenderable() && !hasSecondary) {
|
|
57
118
|
this.foundHash[index] = 1;
|
|
58
119
|
return;
|
|
59
120
|
}
|
|
@@ -61,31 +122,83 @@ export class VoxelGeometryBuilderCacheSpace {
|
|
|
61
122
|
const voxelId = voxel.getId();
|
|
62
123
|
this.trueVoxelCache[index] = trueVoxelId;
|
|
63
124
|
this.voxelCache[index] = voxelId;
|
|
64
|
-
|
|
125
|
+
let secondaryOpaque = false;
|
|
126
|
+
let secondaryTrueVoxelId = 0;
|
|
127
|
+
let secondaryVoxelId = 0;
|
|
128
|
+
if (hasSecondary) {
|
|
129
|
+
voxel.setSecondary(true);
|
|
130
|
+
secondaryOpaque = voxel.isOpaque();
|
|
131
|
+
secondaryTrueVoxelId = voxel.getVoxelId();
|
|
132
|
+
secondaryVoxelId = voxel.getId();
|
|
133
|
+
this.hasSecondary[index] = 1;
|
|
134
|
+
this.secondaryVoxelCache[index] = secondaryVoxelId;
|
|
135
|
+
this.secondaryTrueVoxelCache[index] = secondaryTrueVoxelId;
|
|
136
|
+
voxel.setSecondary(false);
|
|
137
|
+
}
|
|
138
|
+
if (voxel.isOpaque() || secondaryOpaque) {
|
|
139
|
+
this.foundHash[index] = 2;
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
this.foundHash[index] = 3;
|
|
143
|
+
}
|
|
144
|
+
this.fullBlock[index] = voxel.tags["dve_full_block"] ? 1 : 0;
|
|
65
145
|
//no ao
|
|
66
146
|
this.noCastAO[index] = voxel.isLightSource() || voxel.noAO() ? 1 : 0;
|
|
147
|
+
if (hasSecondary) {
|
|
148
|
+
voxel.setSecondary(true);
|
|
149
|
+
this.secondaryNoCastAO[index] =
|
|
150
|
+
voxel.isLightSource() || voxel.noAO() ? 1 : 0;
|
|
151
|
+
voxel.setSecondary(false);
|
|
152
|
+
}
|
|
67
153
|
this.voxelCursor.copy(voxel).process();
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
154
|
+
let secondaryRelationalState = 0;
|
|
155
|
+
let secondaryRelationalMod = 0;
|
|
156
|
+
const relationalBuilder = VoxelSchemas.reltionalStateBuilderMap[VoxelLUT.modelsIndex[trueVoxelId]];
|
|
157
|
+
relationalBuilder.position.x = x;
|
|
158
|
+
relationalBuilder.position.y = y;
|
|
159
|
+
relationalBuilder.position.z = z;
|
|
160
|
+
relationalBuilder.voxel = this.voxelCursor;
|
|
161
|
+
relationalBuilder.dataCursor = dataCursor;
|
|
162
|
+
const reltionalState = relationalBuilder.buildState();
|
|
75
163
|
this.reltionalStateCache[index] = reltionalState;
|
|
76
|
-
|
|
164
|
+
if (hasSecondary) {
|
|
165
|
+
const relationalBuilder = VoxelSchemas.reltionalStateBuilderMap[VoxelLUT.modelsIndex[secondaryTrueVoxelId]];
|
|
166
|
+
relationalBuilder.position.x = x;
|
|
167
|
+
relationalBuilder.position.y = y;
|
|
168
|
+
relationalBuilder.position.z = z;
|
|
169
|
+
relationalBuilder.voxel = this.voxelCursor;
|
|
170
|
+
relationalBuilder.dataCursor = dataCursor;
|
|
171
|
+
this.voxelCursor.setSecondary(true);
|
|
172
|
+
secondaryRelationalState = relationalBuilder.buildState();
|
|
173
|
+
this.secondaryReltionalStateCache[index] = secondaryRelationalState;
|
|
174
|
+
this.voxelCursor.setSecondary(false);
|
|
175
|
+
}
|
|
176
|
+
const relationalModBuilder = VoxelSchemas.reltionalModBuilderMap[trueVoxelId];
|
|
77
177
|
let reltionalMod = 0;
|
|
78
|
-
if (
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
reltionalMod =
|
|
178
|
+
if (relationalModBuilder) {
|
|
179
|
+
relationalModBuilder.position.x = x;
|
|
180
|
+
relationalModBuilder.position.y = y;
|
|
181
|
+
relationalModBuilder.position.z = z;
|
|
182
|
+
relationalModBuilder.voxel = this.voxelCursor;
|
|
183
|
+
relationalModBuilder.dataCursor = dataCursor;
|
|
184
|
+
reltionalMod = relationalModBuilder.buildState();
|
|
85
185
|
}
|
|
86
|
-
|
|
87
|
-
|
|
186
|
+
if (hasSecondary) {
|
|
187
|
+
const relationalModBuilder = VoxelSchemas.reltionalModBuilderMap[secondaryTrueVoxelId];
|
|
188
|
+
if (relationalModBuilder) {
|
|
189
|
+
relationalModBuilder.position.x = x;
|
|
190
|
+
relationalModBuilder.position.y = y;
|
|
191
|
+
relationalModBuilder.position.z = z;
|
|
192
|
+
relationalModBuilder.voxel = this.voxelCursor;
|
|
193
|
+
relationalModBuilder.dataCursor = dataCursor;
|
|
194
|
+
this.voxelCursor.setSecondary(true);
|
|
195
|
+
secondaryRelationalMod = relationalModBuilder.buildState();
|
|
196
|
+
this.voxelCursor.setSecondary(false);
|
|
197
|
+
}
|
|
88
198
|
}
|
|
89
199
|
this.reltionalVoxelCache[index] = VoxelLUT.getReltionalVoxelId(trueVoxelId, reltionalState, reltionalMod);
|
|
200
|
+
if (hasSecondary) {
|
|
201
|
+
this.secondaryReltionalVoxelCache[index] = VoxelLUT.getReltionalVoxelId(secondaryTrueVoxelId, secondaryRelationalState, secondaryRelationalMod);
|
|
202
|
+
}
|
|
90
203
|
}
|
|
91
204
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { DataCursorInterface } from "../../../Voxels/Cursor/DataCursor.interface";
|
|
2
|
+
import { Vec3Array, Vector3Like } from "@amodx/math";
|
|
3
|
+
import { VoxelCursor } from "../../../Voxels/Cursor/VoxelCursor";
|
|
4
|
+
export declare class VoxelGeometryBuilderCacheSpace {
|
|
5
|
+
bounds: Vector3Like;
|
|
6
|
+
foundHash: Uint8Array;
|
|
7
|
+
lightCache: Int32Array;
|
|
8
|
+
private voxelCache;
|
|
9
|
+
private trueVoxelCache;
|
|
10
|
+
private reltionalVoxelCache;
|
|
11
|
+
private reltionalStateCache;
|
|
12
|
+
secondaryVoxelCache: Uint16Array;
|
|
13
|
+
secondaryTrueVoxelCache: Uint16Array;
|
|
14
|
+
secondaryReltionalVoxelCache: Uint16Array;
|
|
15
|
+
secondaryReltionalStateCache: Uint16Array;
|
|
16
|
+
hasSecondary: Uint8Array;
|
|
17
|
+
noCastAO: Uint8Array;
|
|
18
|
+
secondaryNoCastAO: Uint8Array;
|
|
19
|
+
fullBlock: Uint8Array;
|
|
20
|
+
offset: Vec3Array;
|
|
21
|
+
voxelCursor: VoxelCursor;
|
|
22
|
+
constructor(bounds: Vector3Like);
|
|
23
|
+
start(x: number, y: number, z: number): void;
|
|
24
|
+
getIndex(x: number, y: number, z: number): number;
|
|
25
|
+
getHash(dataCursor: DataCursorInterface, x: number, y: number, z: number): number;
|
|
26
|
+
getNoCastAO(index: number, secondary?: boolean): boolean;
|
|
27
|
+
getTrueVoxelId(index: number, secondary?: boolean): number;
|
|
28
|
+
getVoxelId(index: number, secondary?: boolean): number;
|
|
29
|
+
getRelationalState(index: number, secondary?: boolean): number;
|
|
30
|
+
getRelationalVoxelId(index: number, secondary?: boolean): number;
|
|
31
|
+
getHasSecondary(index: number): number;
|
|
32
|
+
private hashState;
|
|
33
|
+
}
|