@divinevoxel/vlox 0.0.79 → 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/Compile/BuildCompiled.d.ts +1 -1
- package/Voxels/Functions/Geometry/Inputs/BuildBoxInputs.d.ts +1 -1
- package/Voxels/Functions/Geometry/Inputs/BuildCustomInputs.d.ts +1 -1
- package/Voxels/Functions/Geometry/Inputs/BuildQuadInputs.d.ts +1 -1
- package/Voxels/Functions/Geometry/Inputs/BuildTriangleInputs.d.ts +1 -1
- 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,4 @@
|
|
|
1
1
|
import { Vector3Like, Vector2Like } from "@amodx/math";
|
|
2
|
-
import { TriangleVerticies } from "../Geometry.types";
|
|
3
2
|
export class TriangleVertexData {
|
|
4
3
|
vertices;
|
|
5
4
|
constructor(vertices) {
|
|
@@ -7,9 +6,9 @@ export class TriangleVertexData {
|
|
|
7
6
|
}
|
|
8
7
|
toArray() {
|
|
9
8
|
return [
|
|
10
|
-
this.vertices[TriangleVerticies.One],
|
|
11
|
-
this.vertices[TriangleVerticies.Two],
|
|
12
|
-
this.vertices[TriangleVerticies.Three],
|
|
9
|
+
this.vertices[0 /* TriangleVerticies.One */],
|
|
10
|
+
this.vertices[1 /* TriangleVerticies.Two */],
|
|
11
|
+
this.vertices[2 /* TriangleVerticies.Three */],
|
|
13
12
|
];
|
|
14
13
|
}
|
|
15
14
|
setVertex(vertex, value) {
|
|
@@ -19,39 +18,39 @@ export class TriangleVertexData {
|
|
|
19
18
|
return this.vertices[vertex];
|
|
20
19
|
}
|
|
21
20
|
setAll(value) {
|
|
22
|
-
this.vertices[TriangleVerticies.One] = value;
|
|
23
|
-
this.vertices[TriangleVerticies.Two] = value;
|
|
24
|
-
this.vertices[TriangleVerticies.Three] = value;
|
|
21
|
+
this.vertices[0 /* TriangleVerticies.One */] = value;
|
|
22
|
+
this.vertices[1 /* TriangleVerticies.Two */] = value;
|
|
23
|
+
this.vertices[2 /* TriangleVerticies.Three */] = value;
|
|
25
24
|
}
|
|
26
25
|
set(v1, v2, v3) {
|
|
27
|
-
this.vertices[TriangleVerticies.One] = v1;
|
|
28
|
-
this.vertices[TriangleVerticies.Two] = v2;
|
|
29
|
-
this.vertices[TriangleVerticies.Three] = v3;
|
|
26
|
+
this.vertices[0 /* TriangleVerticies.One */] = v1;
|
|
27
|
+
this.vertices[1 /* TriangleVerticies.Two */] = v2;
|
|
28
|
+
this.vertices[2 /* TriangleVerticies.Three */] = v3;
|
|
30
29
|
}
|
|
31
30
|
isEqualTo(v1, v2, v3) {
|
|
32
|
-
if (this.vertices[TriangleVerticies.One] != v1)
|
|
31
|
+
if (this.vertices[0 /* TriangleVerticies.One */] != v1)
|
|
33
32
|
return false;
|
|
34
|
-
if (this.vertices[TriangleVerticies.Two] != v2)
|
|
33
|
+
if (this.vertices[1 /* TriangleVerticies.Two */] != v2)
|
|
35
34
|
return false;
|
|
36
|
-
if (this.vertices[TriangleVerticies.Three] != v3)
|
|
35
|
+
if (this.vertices[2 /* TriangleVerticies.Three */] != v3)
|
|
37
36
|
return false;
|
|
38
37
|
return true;
|
|
39
38
|
}
|
|
40
39
|
isAllEqualTo(value) {
|
|
41
|
-
if (this.vertices[TriangleVerticies.One] != value)
|
|
40
|
+
if (this.vertices[0 /* TriangleVerticies.One */] != value)
|
|
42
41
|
return false;
|
|
43
|
-
if (this.vertices[TriangleVerticies.Two] != value)
|
|
42
|
+
if (this.vertices[1 /* TriangleVerticies.Two */] != value)
|
|
44
43
|
return false;
|
|
45
|
-
if (this.vertices[TriangleVerticies.Three] != value)
|
|
44
|
+
if (this.vertices[2 /* TriangleVerticies.Three */] != value)
|
|
46
45
|
return false;
|
|
47
46
|
return true;
|
|
48
47
|
}
|
|
49
48
|
[Symbol.iterator]() {
|
|
50
|
-
let index = TriangleVerticies.One
|
|
49
|
+
let index = 0 /* TriangleVerticies.One */;
|
|
51
50
|
const items = this.vertices;
|
|
52
51
|
return {
|
|
53
52
|
next() {
|
|
54
|
-
if (index < TriangleVerticies.Three) {
|
|
53
|
+
if (index < 2 /* TriangleVerticies.Three */) {
|
|
55
54
|
return { value: items[index++], done: false };
|
|
56
55
|
}
|
|
57
56
|
else {
|
|
@@ -62,9 +61,9 @@ export class TriangleVertexData {
|
|
|
62
61
|
}
|
|
63
62
|
clone() {
|
|
64
63
|
return new TriangleVertexData([
|
|
65
|
-
structuredClone(this.vertices[TriangleVerticies.One]),
|
|
66
|
-
structuredClone(this.vertices[TriangleVerticies.Two]),
|
|
67
|
-
structuredClone(this.vertices[TriangleVerticies.Three]),
|
|
64
|
+
structuredClone(this.vertices[0 /* TriangleVerticies.One */]),
|
|
65
|
+
structuredClone(this.vertices[1 /* TriangleVerticies.Two */]),
|
|
66
|
+
structuredClone(this.vertices[2 /* TriangleVerticies.Three */]),
|
|
68
67
|
]);
|
|
69
68
|
}
|
|
70
69
|
}
|
|
@@ -79,9 +78,9 @@ export class TriangleVector3VertexData extends TriangleVertexData {
|
|
|
79
78
|
this.vertices = vertices;
|
|
80
79
|
}
|
|
81
80
|
setFromQuadData(vertexData) {
|
|
82
|
-
Vector3Like.Copy(this.vertices[TriangleVerticies.One], vertexData.vertices[TriangleVerticies.One]);
|
|
83
|
-
Vector3Like.Copy(this.vertices[TriangleVerticies.Two], vertexData.vertices[TriangleVerticies.Two]);
|
|
84
|
-
Vector3Like.Copy(this.vertices[TriangleVerticies.Three], vertexData.vertices[TriangleVerticies.Three]);
|
|
81
|
+
Vector3Like.Copy(this.vertices[0 /* TriangleVerticies.One */], vertexData.vertices[0 /* TriangleVerticies.One */]);
|
|
82
|
+
Vector3Like.Copy(this.vertices[1 /* TriangleVerticies.Two */], vertexData.vertices[1 /* TriangleVerticies.Two */]);
|
|
83
|
+
Vector3Like.Copy(this.vertices[2 /* TriangleVerticies.Three */], vertexData.vertices[2 /* TriangleVerticies.Three */]);
|
|
85
84
|
}
|
|
86
85
|
addToVertex(vertex, value) {
|
|
87
86
|
Vector3Like.AddInPlace(this.vertices[vertex], value);
|
|
@@ -90,30 +89,30 @@ export class TriangleVector3VertexData extends TriangleVertexData {
|
|
|
90
89
|
Vector3Like.SubtractInPlace(this.vertices[vertex], value);
|
|
91
90
|
}
|
|
92
91
|
addAll(value) {
|
|
93
|
-
this.addToVertex(TriangleVerticies.One
|
|
94
|
-
this.addToVertex(TriangleVerticies.Two
|
|
95
|
-
this.addToVertex(TriangleVerticies.Three
|
|
92
|
+
this.addToVertex(0 /* TriangleVerticies.One */, value);
|
|
93
|
+
this.addToVertex(1 /* TriangleVerticies.Two */, value);
|
|
94
|
+
this.addToVertex(2 /* TriangleVerticies.Three */, value);
|
|
96
95
|
}
|
|
97
96
|
subtractAll(value) {
|
|
98
|
-
this.subtractFromVertex(TriangleVerticies.One
|
|
99
|
-
this.subtractFromVertex(TriangleVerticies.Two
|
|
100
|
-
this.subtractFromVertex(TriangleVerticies.Three
|
|
97
|
+
this.subtractFromVertex(0 /* TriangleVerticies.One */, value);
|
|
98
|
+
this.subtractFromVertex(1 /* TriangleVerticies.Two */, value);
|
|
99
|
+
this.subtractFromVertex(2 /* TriangleVerticies.Three */, value);
|
|
101
100
|
}
|
|
102
101
|
isEqualTo(v1, v2, v3) {
|
|
103
|
-
return (Vector3Like.Equals(this.vertices[TriangleVerticies.One], v1) &&
|
|
104
|
-
Vector3Like.Equals(this.vertices[TriangleVerticies.Two], v2) &&
|
|
105
|
-
Vector3Like.Equals(this.vertices[TriangleVerticies.Three], v3));
|
|
102
|
+
return (Vector3Like.Equals(this.vertices[0 /* TriangleVerticies.One */], v1) &&
|
|
103
|
+
Vector3Like.Equals(this.vertices[1 /* TriangleVerticies.Two */], v2) &&
|
|
104
|
+
Vector3Like.Equals(this.vertices[2 /* TriangleVerticies.Three */], v3));
|
|
106
105
|
}
|
|
107
106
|
isAllEqualTo(v1) {
|
|
108
|
-
return (Vector3Like.Equals(this.vertices[TriangleVerticies.One], v1) &&
|
|
109
|
-
Vector3Like.Equals(this.vertices[TriangleVerticies.Two], v1) &&
|
|
110
|
-
Vector3Like.Equals(this.vertices[TriangleVerticies.Three], v1));
|
|
107
|
+
return (Vector3Like.Equals(this.vertices[0 /* TriangleVerticies.One */], v1) &&
|
|
108
|
+
Vector3Like.Equals(this.vertices[1 /* TriangleVerticies.Two */], v1) &&
|
|
109
|
+
Vector3Like.Equals(this.vertices[2 /* TriangleVerticies.Three */], v1));
|
|
111
110
|
}
|
|
112
111
|
clone() {
|
|
113
112
|
return new TriangleVector3VertexData([
|
|
114
|
-
Vector3Like.Clone(this.vertices[TriangleVerticies.One]),
|
|
115
|
-
Vector3Like.Clone(this.vertices[TriangleVerticies.Two]),
|
|
116
|
-
Vector3Like.Clone(this.vertices[TriangleVerticies.Three]),
|
|
113
|
+
Vector3Like.Clone(this.vertices[0 /* TriangleVerticies.One */]),
|
|
114
|
+
Vector3Like.Clone(this.vertices[1 /* TriangleVerticies.Two */]),
|
|
115
|
+
Vector3Like.Clone(this.vertices[2 /* TriangleVerticies.Three */]),
|
|
117
116
|
]);
|
|
118
117
|
}
|
|
119
118
|
toVec3Array() {
|
|
@@ -135,9 +134,9 @@ export class TriangleVector2VertexData extends TriangleVertexData {
|
|
|
135
134
|
this.vertices = vertices;
|
|
136
135
|
}
|
|
137
136
|
setFromQuadData(vertexData) {
|
|
138
|
-
Vector2Like.Copy(this.vertices[TriangleVerticies.One], vertexData.vertices[TriangleVerticies.One]);
|
|
139
|
-
Vector2Like.Copy(this.vertices[TriangleVerticies.Two], vertexData.vertices[TriangleVerticies.Two]);
|
|
140
|
-
Vector2Like.Copy(this.vertices[TriangleVerticies.Three], vertexData.vertices[TriangleVerticies.Three]);
|
|
137
|
+
Vector2Like.Copy(this.vertices[0 /* TriangleVerticies.One */], vertexData.vertices[0 /* TriangleVerticies.One */]);
|
|
138
|
+
Vector2Like.Copy(this.vertices[1 /* TriangleVerticies.Two */], vertexData.vertices[1 /* TriangleVerticies.Two */]);
|
|
139
|
+
Vector2Like.Copy(this.vertices[2 /* TriangleVerticies.Three */], vertexData.vertices[2 /* TriangleVerticies.Three */]);
|
|
141
140
|
}
|
|
142
141
|
addToVertex(vertex, value) {
|
|
143
142
|
Vector2Like.AddInPlace(this.vertices[vertex], value);
|
|
@@ -146,24 +145,24 @@ export class TriangleVector2VertexData extends TriangleVertexData {
|
|
|
146
145
|
Vector2Like.SubtractInPlace(this.vertices[vertex], value);
|
|
147
146
|
}
|
|
148
147
|
addAll(value) {
|
|
149
|
-
this.addToVertex(TriangleVerticies.One
|
|
150
|
-
this.addToVertex(TriangleVerticies.Two
|
|
151
|
-
this.addToVertex(TriangleVerticies.Three
|
|
148
|
+
this.addToVertex(0 /* TriangleVerticies.One */, value);
|
|
149
|
+
this.addToVertex(1 /* TriangleVerticies.Two */, value);
|
|
150
|
+
this.addToVertex(2 /* TriangleVerticies.Three */, value);
|
|
152
151
|
}
|
|
153
152
|
subtractAll(value) {
|
|
154
|
-
this.subtractFromVertex(TriangleVerticies.One
|
|
155
|
-
this.subtractFromVertex(TriangleVerticies.Two
|
|
156
|
-
this.subtractFromVertex(TriangleVerticies.Three
|
|
153
|
+
this.subtractFromVertex(0 /* TriangleVerticies.One */, value);
|
|
154
|
+
this.subtractFromVertex(1 /* TriangleVerticies.Two */, value);
|
|
155
|
+
this.subtractFromVertex(2 /* TriangleVerticies.Three */, value);
|
|
157
156
|
}
|
|
158
157
|
isEqualTo(v1, v2, v3) {
|
|
159
|
-
return (Vector2Like.Equals(this.vertices[TriangleVerticies.One], v1) &&
|
|
160
|
-
Vector2Like.Equals(this.vertices[TriangleVerticies.Two], v2) &&
|
|
161
|
-
Vector2Like.Equals(this.vertices[TriangleVerticies.Three], v3));
|
|
158
|
+
return (Vector2Like.Equals(this.vertices[0 /* TriangleVerticies.One */], v1) &&
|
|
159
|
+
Vector2Like.Equals(this.vertices[1 /* TriangleVerticies.Two */], v2) &&
|
|
160
|
+
Vector2Like.Equals(this.vertices[2 /* TriangleVerticies.Three */], v3));
|
|
162
161
|
}
|
|
163
162
|
isAllEqualTo(v1) {
|
|
164
|
-
return (Vector2Like.Equals(this.vertices[TriangleVerticies.One], v1) &&
|
|
165
|
-
Vector2Like.Equals(this.vertices[TriangleVerticies.Two], v1) &&
|
|
166
|
-
Vector2Like.Equals(this.vertices[TriangleVerticies.Three], v1));
|
|
163
|
+
return (Vector2Like.Equals(this.vertices[0 /* TriangleVerticies.One */], v1) &&
|
|
164
|
+
Vector2Like.Equals(this.vertices[1 /* TriangleVerticies.Two */], v1) &&
|
|
165
|
+
Vector2Like.Equals(this.vertices[2 /* TriangleVerticies.Three */], v1));
|
|
167
166
|
}
|
|
168
167
|
toVec2Array() {
|
|
169
168
|
return [
|
|
@@ -174,9 +173,9 @@ export class TriangleVector2VertexData extends TriangleVertexData {
|
|
|
174
173
|
}
|
|
175
174
|
clone() {
|
|
176
175
|
return new TriangleVector2VertexData([
|
|
177
|
-
Vector2Like.Clone(this.vertices[TriangleVerticies.One]),
|
|
178
|
-
Vector2Like.Clone(this.vertices[TriangleVerticies.Two]),
|
|
179
|
-
Vector2Like.Clone(this.vertices[TriangleVerticies.Three]),
|
|
176
|
+
Vector2Like.Clone(this.vertices[0 /* TriangleVerticies.One */]),
|
|
177
|
+
Vector2Like.Clone(this.vertices[1 /* TriangleVerticies.Two */]),
|
|
178
|
+
Vector2Like.Clone(this.vertices[2 /* TriangleVerticies.Three */]),
|
|
180
179
|
]);
|
|
181
180
|
}
|
|
182
181
|
}
|
|
@@ -187,77 +186,77 @@ export class TriangleScalarVertexData extends TriangleVertexData {
|
|
|
187
186
|
this.vertices = vertices;
|
|
188
187
|
}
|
|
189
188
|
setFromQuadData(vertexData) {
|
|
190
|
-
this.vertices[TriangleVerticies.One] =
|
|
191
|
-
vertexData.vertices[TriangleVerticies.One];
|
|
192
|
-
this.vertices[TriangleVerticies.Two] =
|
|
193
|
-
vertexData.vertices[TriangleVerticies.Two];
|
|
194
|
-
this.vertices[TriangleVerticies.Three] =
|
|
195
|
-
vertexData.vertices[TriangleVerticies.Three];
|
|
189
|
+
this.vertices[0 /* TriangleVerticies.One */] =
|
|
190
|
+
vertexData.vertices[0 /* TriangleVerticies.One */];
|
|
191
|
+
this.vertices[1 /* TriangleVerticies.Two */] =
|
|
192
|
+
vertexData.vertices[1 /* TriangleVerticies.Two */];
|
|
193
|
+
this.vertices[2 /* TriangleVerticies.Three */] =
|
|
194
|
+
vertexData.vertices[2 /* TriangleVerticies.Three */];
|
|
196
195
|
}
|
|
197
196
|
subtractFromVertex(vertex, value) {
|
|
198
197
|
this.vertices[vertex] -= value;
|
|
199
198
|
}
|
|
200
199
|
addAll(value) {
|
|
201
|
-
this.vertices[TriangleVerticies.One] += value;
|
|
202
|
-
this.vertices[TriangleVerticies.Two] += value;
|
|
203
|
-
this.vertices[TriangleVerticies.Three] += value;
|
|
200
|
+
this.vertices[0 /* TriangleVerticies.One */] += value;
|
|
201
|
+
this.vertices[1 /* TriangleVerticies.Two */] += value;
|
|
202
|
+
this.vertices[2 /* TriangleVerticies.Three */] += value;
|
|
204
203
|
}
|
|
205
204
|
add(v1, v2, v3, v4) {
|
|
206
|
-
this.vertices[TriangleVerticies.One] += v1;
|
|
207
|
-
this.vertices[TriangleVerticies.Two] += v2;
|
|
208
|
-
this.vertices[TriangleVerticies.Three] += v3;
|
|
205
|
+
this.vertices[0 /* TriangleVerticies.One */] += v1;
|
|
206
|
+
this.vertices[1 /* TriangleVerticies.Two */] += v2;
|
|
207
|
+
this.vertices[2 /* TriangleVerticies.Three */] += v3;
|
|
209
208
|
}
|
|
210
209
|
subtractAll(value) {
|
|
211
|
-
this.vertices[TriangleVerticies.One] -= value;
|
|
212
|
-
this.vertices[TriangleVerticies.Two] -= value;
|
|
213
|
-
this.vertices[TriangleVerticies.Three] -= value;
|
|
210
|
+
this.vertices[0 /* TriangleVerticies.One */] -= value;
|
|
211
|
+
this.vertices[1 /* TriangleVerticies.Two */] -= value;
|
|
212
|
+
this.vertices[2 /* TriangleVerticies.Three */] -= value;
|
|
214
213
|
}
|
|
215
214
|
subtract(v1, v2, v3, v4) {
|
|
216
|
-
this.vertices[TriangleVerticies.One] += v1;
|
|
217
|
-
this.vertices[TriangleVerticies.Two] += v2;
|
|
218
|
-
this.vertices[TriangleVerticies.Three] += v3;
|
|
215
|
+
this.vertices[0 /* TriangleVerticies.One */] += v1;
|
|
216
|
+
this.vertices[1 /* TriangleVerticies.Two */] += v2;
|
|
217
|
+
this.vertices[2 /* TriangleVerticies.Three */] += v3;
|
|
219
218
|
}
|
|
220
219
|
isGreaterThan(v1, v2, v3, v4) {
|
|
221
|
-
if (this.vertices[TriangleVerticies.One] < v1)
|
|
220
|
+
if (this.vertices[0 /* TriangleVerticies.One */] < v1)
|
|
222
221
|
return false;
|
|
223
|
-
if (this.vertices[TriangleVerticies.Two] < v2)
|
|
222
|
+
if (this.vertices[1 /* TriangleVerticies.Two */] < v2)
|
|
224
223
|
return false;
|
|
225
|
-
if (this.vertices[TriangleVerticies.Three] < v3)
|
|
224
|
+
if (this.vertices[2 /* TriangleVerticies.Three */] < v3)
|
|
226
225
|
return false;
|
|
227
226
|
return true;
|
|
228
227
|
}
|
|
229
228
|
isAllGreaterThan(value) {
|
|
230
|
-
if (this.vertices[TriangleVerticies.One] < value)
|
|
229
|
+
if (this.vertices[0 /* TriangleVerticies.One */] < value)
|
|
231
230
|
return false;
|
|
232
|
-
if (this.vertices[TriangleVerticies.Two] < value)
|
|
231
|
+
if (this.vertices[1 /* TriangleVerticies.Two */] < value)
|
|
233
232
|
return false;
|
|
234
|
-
if (this.vertices[TriangleVerticies.Three] < value)
|
|
233
|
+
if (this.vertices[2 /* TriangleVerticies.Three */] < value)
|
|
235
234
|
return false;
|
|
236
235
|
return true;
|
|
237
236
|
}
|
|
238
237
|
isLessThan(v1, v2, v3, v4) {
|
|
239
|
-
if (this.vertices[TriangleVerticies.One] > v1)
|
|
238
|
+
if (this.vertices[0 /* TriangleVerticies.One */] > v1)
|
|
240
239
|
return false;
|
|
241
|
-
if (this.vertices[TriangleVerticies.Two] > v2)
|
|
240
|
+
if (this.vertices[1 /* TriangleVerticies.Two */] > v2)
|
|
242
241
|
return false;
|
|
243
|
-
if (this.vertices[TriangleVerticies.Three] > v3)
|
|
242
|
+
if (this.vertices[2 /* TriangleVerticies.Three */] > v3)
|
|
244
243
|
return false;
|
|
245
244
|
return true;
|
|
246
245
|
}
|
|
247
246
|
isAllLessThan(value) {
|
|
248
|
-
if (this.vertices[TriangleVerticies.One] > value)
|
|
247
|
+
if (this.vertices[0 /* TriangleVerticies.One */] > value)
|
|
249
248
|
return false;
|
|
250
|
-
if (this.vertices[TriangleVerticies.Two] > value)
|
|
249
|
+
if (this.vertices[1 /* TriangleVerticies.Two */] > value)
|
|
251
250
|
return false;
|
|
252
|
-
if (this.vertices[TriangleVerticies.Three] > value)
|
|
251
|
+
if (this.vertices[2 /* TriangleVerticies.Three */] > value)
|
|
253
252
|
return false;
|
|
254
253
|
return true;
|
|
255
254
|
}
|
|
256
255
|
clone() {
|
|
257
256
|
return new TriangleScalarVertexData([
|
|
258
|
-
this.vertices[TriangleVerticies.One],
|
|
259
|
-
this.vertices[TriangleVerticies.Two],
|
|
260
|
-
this.vertices[TriangleVerticies.Three],
|
|
257
|
+
this.vertices[0 /* TriangleVerticies.One */],
|
|
258
|
+
this.vertices[1 /* TriangleVerticies.Two */],
|
|
259
|
+
this.vertices[2 /* TriangleVerticies.Three */],
|
|
261
260
|
]);
|
|
262
261
|
}
|
|
263
262
|
}
|
|
@@ -11,7 +11,7 @@ export declare class ProtoMesh {
|
|
|
11
11
|
constructor(vertexFloatSize: number);
|
|
12
12
|
create(): {
|
|
13
13
|
vertexArray: Float32Array<ArrayBuffer>;
|
|
14
|
-
indiciesArray:
|
|
14
|
+
indiciesArray: Uint16Array<ArrayBuffer> | Uint32Array<ArrayBuffer>;
|
|
15
15
|
};
|
|
16
16
|
addVerticies(vertexCount: number, indicesCount: number): void;
|
|
17
17
|
clear(): void;
|
|
@@ -14,47 +14,40 @@ export class ProtoMesh {
|
|
|
14
14
|
this.indices = new ProtoIndiceBuffer(1024);
|
|
15
15
|
}
|
|
16
16
|
create() {
|
|
17
|
-
const
|
|
18
|
-
const vertexArray = new Float32Array(
|
|
19
|
-
const vertexBuffers = this.buffer.
|
|
20
|
-
let
|
|
21
|
-
let
|
|
22
|
-
for (let i = 0; i < vertexBuffers.length; i++) {
|
|
17
|
+
const totalVertices = this.vertexCount * this.vertexFloatSize;
|
|
18
|
+
const vertexArray = new Float32Array(totalVertices);
|
|
19
|
+
const vertexBuffers = this.buffer._float32Views;
|
|
20
|
+
let offset = 0;
|
|
21
|
+
for (let i = 0; i < vertexBuffers.length && offset < totalVertices; i++) {
|
|
23
22
|
const buffer = vertexBuffers[i];
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
done = true;
|
|
29
|
-
break;
|
|
30
|
-
}
|
|
23
|
+
const remaining = totalVertices - offset;
|
|
24
|
+
if (buffer.length <= remaining) {
|
|
25
|
+
vertexArray.set(buffer, offset);
|
|
26
|
+
offset += buffer.length;
|
|
31
27
|
}
|
|
32
|
-
|
|
28
|
+
else {
|
|
29
|
+
vertexArray.set(buffer.subarray(0, remaining), offset);
|
|
33
30
|
break;
|
|
31
|
+
}
|
|
34
32
|
}
|
|
35
33
|
const indiciesArray = this.indicieCount > 65535
|
|
36
34
|
? new Uint32Array(this.indicieCount)
|
|
37
35
|
: new Uint16Array(this.indicieCount);
|
|
38
36
|
const indiceBuffers = this.indices._buffers;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
for (let i = 0; i < indiceBuffers.length; i++) {
|
|
37
|
+
offset = 0;
|
|
38
|
+
for (let i = 0; i < indiceBuffers.length && offset < this.indicieCount; i++) {
|
|
42
39
|
const buffer = indiceBuffers[i];
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
done = true;
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
40
|
+
const remaining = this.indicieCount - offset;
|
|
41
|
+
if (buffer.length <= remaining) {
|
|
42
|
+
indiciesArray.set(buffer, offset);
|
|
43
|
+
offset += buffer.length;
|
|
50
44
|
}
|
|
51
|
-
|
|
45
|
+
else {
|
|
46
|
+
indiciesArray.set(buffer.subarray(0, remaining), offset);
|
|
52
47
|
break;
|
|
48
|
+
}
|
|
53
49
|
}
|
|
54
|
-
return {
|
|
55
|
-
vertexArray,
|
|
56
|
-
indiciesArray,
|
|
57
|
-
};
|
|
50
|
+
return { vertexArray, indiciesArray };
|
|
58
51
|
}
|
|
59
52
|
addVerticies(vertexCount, indicesCount) {
|
|
60
53
|
this.vertexCount += vertexCount;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
export declare class ProtoVertexBuffer {
|
|
2
2
|
vertexFloatSize: number;
|
|
3
3
|
sectorVertexSize: number;
|
|
4
|
-
|
|
4
|
+
_float32Views: Float32Array[];
|
|
5
|
+
_uint32Views: Uint32Array[];
|
|
5
6
|
sectorSize: number;
|
|
6
7
|
constructor(vertexFloatSize: number, sectorVertexSize: number, startingSectorSize?: number);
|
|
7
|
-
|
|
8
|
+
currentFloat32Array: Float32Array;
|
|
9
|
+
currentUint32Array: Uint32Array;
|
|
8
10
|
curentIndex: number;
|
|
9
11
|
_index: number;
|
|
10
12
|
setIndex(index: number): void;
|
|
@@ -1,28 +1,36 @@
|
|
|
1
1
|
export class ProtoVertexBuffer {
|
|
2
2
|
vertexFloatSize;
|
|
3
3
|
sectorVertexSize;
|
|
4
|
-
|
|
4
|
+
_float32Views = [];
|
|
5
|
+
_uint32Views = [];
|
|
5
6
|
sectorSize = 0;
|
|
6
7
|
constructor(vertexFloatSize, sectorVertexSize, startingSectorSize = 8) {
|
|
7
8
|
this.vertexFloatSize = vertexFloatSize;
|
|
8
9
|
this.sectorVertexSize = sectorVertexSize;
|
|
9
10
|
this.sectorSize = vertexFloatSize * sectorVertexSize;
|
|
10
11
|
for (let i = 0; i < startingSectorSize; i++) {
|
|
11
|
-
|
|
12
|
+
const float32Array = new Float32Array(this.sectorSize);
|
|
13
|
+
this._float32Views[i] = float32Array;
|
|
14
|
+
this._uint32Views[i] = new Uint32Array(float32Array.buffer);
|
|
12
15
|
}
|
|
13
16
|
}
|
|
14
|
-
|
|
17
|
+
currentFloat32Array;
|
|
18
|
+
currentUint32Array;
|
|
15
19
|
curentIndex = 0;
|
|
16
20
|
_index = 0;
|
|
17
21
|
setIndex(index) {
|
|
18
22
|
this._index = index;
|
|
19
23
|
const bufferIndex = Math.floor((index * this.vertexFloatSize) / this.sectorSize);
|
|
20
|
-
if (!this.
|
|
21
|
-
|
|
24
|
+
if (!this._float32Views[bufferIndex]) {
|
|
25
|
+
const float32Array = new Float32Array(this.sectorSize);
|
|
26
|
+
this._float32Views[bufferIndex] = float32Array;
|
|
27
|
+
this._uint32Views[bufferIndex] = new Uint32Array(float32Array.buffer);
|
|
28
|
+
}
|
|
22
29
|
this.curentIndex =
|
|
23
30
|
(index * this.vertexFloatSize - bufferIndex * this.sectorSize) /
|
|
24
31
|
this.vertexFloatSize;
|
|
25
|
-
this.
|
|
32
|
+
this.currentFloat32Array = this._float32Views[bufferIndex];
|
|
33
|
+
this.currentUint32Array = this._uint32Views[bufferIndex];
|
|
26
34
|
}
|
|
27
35
|
}
|
|
28
36
|
export class ProtoIndiceBuffer {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Quad } from "../Primitives";
|
|
2
|
-
import { VoxelFaces } from "../../../Math";
|
|
3
2
|
export class Box {
|
|
4
3
|
static Create(points = [
|
|
5
4
|
[0, 0, 0],
|
|
@@ -24,37 +23,37 @@ export class Box {
|
|
|
24
23
|
setPoints(points) {
|
|
25
24
|
const [startX, startY, startZ] = points[0];
|
|
26
25
|
const [endX, endY, endZ] = points[1];
|
|
27
|
-
this.quads[VoxelFaces.Up].setPositions([
|
|
26
|
+
this.quads[0 /* VoxelFaces.Up */].setPositions([
|
|
28
27
|
[endX, endY, endZ],
|
|
29
28
|
[startX, endY, endZ],
|
|
30
29
|
[startX, endY, startZ],
|
|
31
30
|
[endX, endY, startZ],
|
|
32
31
|
]);
|
|
33
|
-
this.quads[VoxelFaces.Down].setPositions([
|
|
32
|
+
this.quads[1 /* VoxelFaces.Down */].setPositions([
|
|
34
33
|
[startX, startY, endZ],
|
|
35
34
|
[endX, startY, endZ],
|
|
36
35
|
[endX, startY, startZ],
|
|
37
36
|
[startX, startY, startZ],
|
|
38
37
|
]);
|
|
39
|
-
this.quads[VoxelFaces.North].setPositions([
|
|
38
|
+
this.quads[2 /* VoxelFaces.North */].setPositions([
|
|
40
39
|
[startX, endY, endZ],
|
|
41
40
|
[endX, endY, endZ],
|
|
42
41
|
[endX, startY, endZ],
|
|
43
42
|
[startX, startY, endZ],
|
|
44
43
|
]);
|
|
45
|
-
this.quads[VoxelFaces.South].setPositions([
|
|
44
|
+
this.quads[3 /* VoxelFaces.South */].setPositions([
|
|
46
45
|
[endX, endY, startZ],
|
|
47
46
|
[startX, endY, startZ],
|
|
48
47
|
[startX, startY, startZ],
|
|
49
48
|
[endX, startY, startZ],
|
|
50
49
|
]);
|
|
51
|
-
this.quads[VoxelFaces.East].setPositions([
|
|
50
|
+
this.quads[4 /* VoxelFaces.East */].setPositions([
|
|
52
51
|
[endX, endY, endZ],
|
|
53
52
|
[endX, endY, startZ],
|
|
54
53
|
[endX, startY, startZ],
|
|
55
54
|
[endX, startY, endZ],
|
|
56
55
|
]);
|
|
57
|
-
this.quads[VoxelFaces.West].setPositions([
|
|
56
|
+
this.quads[5 /* VoxelFaces.West */].setPositions([
|
|
58
57
|
[startX, endY, startZ],
|
|
59
58
|
[startX, endY, endZ],
|
|
60
59
|
[startX, startY, endZ],
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { QuadVerticies } from "../Geometry.types";
|
|
2
1
|
import { AMath, Vector3Like } from "@amodx/math";
|
|
3
2
|
import { VoxelFacesArray } from "../../../Math";
|
|
4
3
|
export function TransformBox(box, transform) {
|
|
@@ -7,10 +6,10 @@ export function TransformBox(box, transform) {
|
|
|
7
6
|
for (const face of VoxelFacesArray) {
|
|
8
7
|
const quad = box.quads[face];
|
|
9
8
|
const vertices = [
|
|
10
|
-
quad.positions.vertices[QuadVerticies.TopRight],
|
|
11
|
-
quad.positions.vertices[QuadVerticies.TopLeft],
|
|
12
|
-
quad.positions.vertices[QuadVerticies.BottomLeft],
|
|
13
|
-
quad.positions.vertices[QuadVerticies.BottomRight],
|
|
9
|
+
quad.positions.vertices[0 /* QuadVerticies.TopRight */],
|
|
10
|
+
quad.positions.vertices[1 /* QuadVerticies.TopLeft */],
|
|
11
|
+
quad.positions.vertices[2 /* QuadVerticies.BottomLeft */],
|
|
12
|
+
quad.positions.vertices[3 /* QuadVerticies.BottomRight */],
|
|
14
13
|
];
|
|
15
14
|
for (const vertex of vertices) {
|
|
16
15
|
const key = `${vertex.x},${vertex.y},${vertex.z}`;
|
|
@@ -128,10 +127,10 @@ export function TransformBox(box, transform) {
|
|
|
128
127
|
for (const face of VoxelFacesArray) {
|
|
129
128
|
const quad = box.quads[face];
|
|
130
129
|
const originalVertices = [
|
|
131
|
-
quad.positions.vertices[QuadVerticies.TopRight],
|
|
132
|
-
quad.positions.vertices[QuadVerticies.TopLeft],
|
|
133
|
-
quad.positions.vertices[QuadVerticies.BottomLeft],
|
|
134
|
-
quad.positions.vertices[QuadVerticies.BottomRight],
|
|
130
|
+
quad.positions.vertices[0 /* QuadVerticies.TopRight */],
|
|
131
|
+
quad.positions.vertices[1 /* QuadVerticies.TopLeft */],
|
|
132
|
+
quad.positions.vertices[2 /* QuadVerticies.BottomLeft */],
|
|
133
|
+
quad.positions.vertices[3 /* QuadVerticies.BottomRight */],
|
|
135
134
|
];
|
|
136
135
|
const transformedVertices = originalVertices.map((vertex) => {
|
|
137
136
|
const key = `${vertex.x},${vertex.y},${vertex.z}`;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { QuadVerticies } from "../Geometry.types";
|
|
2
1
|
import { Quad } from "../Primitives";
|
|
3
2
|
import { AMath, Vector3Like } from "@amodx/math";
|
|
4
3
|
export function TransformQuad(quad, transform) {
|
|
5
|
-
const p1 = { ...quad.positions.vertices[QuadVerticies.TopRight] };
|
|
6
|
-
const p2 = { ...quad.positions.vertices[QuadVerticies.TopLeft] };
|
|
7
|
-
const p3 = { ...quad.positions.vertices[QuadVerticies.BottomLeft] };
|
|
8
|
-
const p4 = { ...quad.positions.vertices[QuadVerticies.BottomRight] };
|
|
4
|
+
const p1 = { ...quad.positions.vertices[0 /* QuadVerticies.TopRight */] };
|
|
5
|
+
const p2 = { ...quad.positions.vertices[1 /* QuadVerticies.TopLeft */] };
|
|
6
|
+
const p3 = { ...quad.positions.vertices[2 /* QuadVerticies.BottomLeft */] };
|
|
7
|
+
const p4 = { ...quad.positions.vertices[3 /* QuadVerticies.BottomRight */] };
|
|
9
8
|
// Create an array of vertices
|
|
10
9
|
const vertices = [p1, p2, p3, p4];
|
|
11
10
|
// Compute the centroid of the quad
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { TriangleVerticies } from "../Geometry.types";
|
|
2
1
|
import { AMath, Vector3Like } from "@amodx/math";
|
|
3
2
|
import { Triangle } from "../Primitives/Triangle";
|
|
4
3
|
export function TransformTriangle(quad, transform) {
|
|
5
|
-
const p1 = { ...quad.positions.vertices[TriangleVerticies.One] };
|
|
6
|
-
const p2 = { ...quad.positions.vertices[TriangleVerticies.Two] };
|
|
7
|
-
const p3 = { ...quad.positions.vertices[TriangleVerticies.Three] };
|
|
4
|
+
const p1 = { ...quad.positions.vertices[0 /* TriangleVerticies.One */] };
|
|
5
|
+
const p2 = { ...quad.positions.vertices[1 /* TriangleVerticies.Two */] };
|
|
6
|
+
const p3 = { ...quad.positions.vertices[2 /* TriangleVerticies.Three */] };
|
|
8
7
|
// Create an array of vertices
|
|
9
8
|
const vertices = [p1, p2, p3];
|
|
10
9
|
// Compute the centroid of the quad
|
package/Mesher/InitMesher.js
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { RenderedMaterials } from "./Voxels/Models/RenderedMaterials";
|
|
2
|
-
import {
|
|
2
|
+
import { VoxelGeometryConstructorRegister } from "./Voxels/Models/VoxelGeometryConstructorRegister.js";
|
|
3
3
|
import { LiquidGeometryNode } from "./Voxels/Models/Nodes/Custom/Liquid/LiquidGeometryNode.js";
|
|
4
|
-
import { VoxelConstructor } from "./Voxels/Models/VoxelConstructor.js";
|
|
5
|
-
import { VoxelLUT } from "../Voxels/Data/VoxelLUT";
|
|
6
4
|
export default function () {
|
|
7
|
-
RenderedMaterials.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
for (const voxel of VoxelLUT.voxelIds._palette) {
|
|
11
|
-
VoxelModelConstructorRegister.registerVoxel(new VoxelConstructor(voxel, RenderedMaterials.meshersMap.get(VoxelLUT.material.getStringId(VoxelLUT.materialMap[VoxelLUT.voxelIds.getNumberId(voxel)]))));
|
|
12
|
-
}
|
|
5
|
+
RenderedMaterials.init();
|
|
6
|
+
VoxelGeometryConstructorRegister.registerCustomNode("liquid", LiquidGeometryNode);
|
|
7
|
+
VoxelGeometryConstructorRegister.init();
|
|
13
8
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { QuadVerticies } from "../../Geometry/Geometry.types";
|
|
2
1
|
import { ItemMeshVertexConstants } from "./ItemMeshVertexStructCursor";
|
|
3
2
|
export function addItemTriangle(builder, tri) {
|
|
4
3
|
if (!builder.mesh)
|
|
@@ -18,11 +17,11 @@ export function addItemTriangle(builder, tri) {
|
|
|
18
17
|
while (sides--) {
|
|
19
18
|
const baseIndex = builder.mesh.vertexCount;
|
|
20
19
|
builder.mesh.buffer.setIndex(baseIndex);
|
|
21
|
-
addVertex(builder.mesh.buffer.curentIndex, builder.mesh.buffer.
|
|
20
|
+
addVertex(builder.mesh.buffer.curentIndex, builder.mesh.buffer.currentFloat32Array, origin, topRightPos, topRightNor, tri.uvs.vertices[0 /* QuadVerticies.TopRight */], texture);
|
|
22
21
|
builder.mesh.buffer.setIndex(baseIndex + 1);
|
|
23
|
-
addVertex(builder.mesh.buffer.curentIndex, builder.mesh.buffer.
|
|
22
|
+
addVertex(builder.mesh.buffer.curentIndex, builder.mesh.buffer.currentFloat32Array, origin, topLeftPos, topLeftNor, tri.uvs.vertices[1 /* QuadVerticies.TopLeft */], texture);
|
|
24
23
|
builder.mesh.buffer.setIndex(baseIndex + 2);
|
|
25
|
-
addVertex(builder.mesh.buffer.curentIndex, builder.mesh.buffer.
|
|
24
|
+
addVertex(builder.mesh.buffer.curentIndex, builder.mesh.buffer.currentFloat32Array, origin, bottomLeftPos, bottomLeftNor, tri.uvs.vertices[2 /* QuadVerticies.BottomLeft */], texture);
|
|
26
25
|
builder.mesh.addVerticies(3, 3);
|
|
27
26
|
}
|
|
28
27
|
if (!tri.doubleSided) {
|
|
@@ -67,13 +66,13 @@ export function addItemQuad(builder, quad) {
|
|
|
67
66
|
let indIndex = builder.mesh.indicieCount;
|
|
68
67
|
const baseIndex = builder.mesh.vertexCount;
|
|
69
68
|
builder.mesh.buffer.setIndex(baseIndex);
|
|
70
|
-
addVertex(builder.mesh.buffer.curentIndex, builder.mesh.buffer.
|
|
69
|
+
addVertex(builder.mesh.buffer.curentIndex, builder.mesh.buffer.currentFloat32Array, origin, topRightPos, topRightNor, quad.uvs.vertices[0 /* QuadVerticies.TopRight */], texture);
|
|
71
70
|
builder.mesh.buffer.setIndex(baseIndex + 1);
|
|
72
|
-
addVertex(builder.mesh.buffer.curentIndex, builder.mesh.buffer.
|
|
71
|
+
addVertex(builder.mesh.buffer.curentIndex, builder.mesh.buffer.currentFloat32Array, origin, topLeftPos, topLeftNor, quad.uvs.vertices[1 /* QuadVerticies.TopLeft */], texture);
|
|
73
72
|
builder.mesh.buffer.setIndex(baseIndex + 2);
|
|
74
|
-
addVertex(builder.mesh.buffer.curentIndex, builder.mesh.buffer.
|
|
73
|
+
addVertex(builder.mesh.buffer.curentIndex, builder.mesh.buffer.currentFloat32Array, origin, bottomLeftPos, bottomLeftNor, quad.uvs.vertices[2 /* QuadVerticies.BottomLeft */], texture);
|
|
75
74
|
builder.mesh.buffer.setIndex(baseIndex + 3);
|
|
76
|
-
addVertex(builder.mesh.buffer.curentIndex, builder.mesh.buffer.
|
|
75
|
+
addVertex(builder.mesh.buffer.curentIndex, builder.mesh.buffer.currentFloat32Array, origin, bottomRightPos, bottomRightNor, quad.uvs.vertices[3 /* QuadVerticies.BottomRight */], texture);
|
|
77
76
|
if (!quad.doubleSided) {
|
|
78
77
|
let index = baseIndex;
|
|
79
78
|
indices.setIndex(indIndex).currentArray[indices.curentIndex] = index;
|