@divinevoxel/vlox 0.0.72 → 0.0.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Contexts/Base/Remote/InitDataSync.js +4 -0
- package/Contexts/Base/Remote/InitWorldDataSync.js +1 -1
- package/Contexts/Render/DivineVoxelEngineRender.d.ts +2 -1
- package/Contexts/World/DivineVoxelEngineWorld.d.ts +2 -1
- package/Init/StartConstructor.js +8 -4
- package/Init/StartWorld.d.ts +1 -1
- package/Math/index.d.ts +5 -1
- package/Mesher/Functions/CompactVoxelMesh.d.ts +2 -2
- package/Mesher/Functions/CompactVoxelMesh.js +1 -1
- package/Mesher/Functions/CompactVoxelSectionMesh.d.ts +4 -0
- package/Mesher/Functions/CompactVoxelSectionMesh.js +112 -0
- package/Mesher/Functions/MeshSection.d.ts +1 -1
- package/Mesher/Functions/MeshSection.js +27 -22
- package/Mesher/Functions/MeshTexture.d.ts +1 -1
- package/Mesher/Functions/MeshTexture.js +3 -4
- package/Mesher/Geomtry/CompactedSectionVoxelMesh.d.ts +23 -0
- package/Mesher/Geomtry/CompactedSectionVoxelMesh.js +144 -0
- 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 +120 -199
- package/Mesher/Geomtry/VoxelMesh.d.ts +1 -1
- package/Mesher/Geomtry/VoxelMesh.js +4 -4
- package/Mesher/Geomtry/VoxelMeshBVHBuilder.d.ts +16 -0
- package/Mesher/Geomtry/VoxelMeshBVHBuilder.js +51 -0
- package/Mesher/Geomtry/VoxelMeshBVHStructCursor.d.ts +22 -0
- package/Mesher/Geomtry/VoxelMeshBVHStructCursor.js +78 -0
- package/Mesher/Geomtry/{Buffers.js → VoxelMeshBuffers.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 +9 -23
- package/Mesher/Models/Common/BoxGeometryNode.js +7 -7
- package/Mesher/Models/Common/Calc/CalcConstants.d.ts +1 -1
- package/Mesher/Models/Common/Calc/CalcConstants.js +1 -1
- package/Mesher/Models/Common/Calc/FaceDataCalc.d.ts +2 -2
- package/Mesher/Models/Common/Calc/FaceDataCalc.js +37 -30
- package/Mesher/Models/Common/QuadGeometryNode.js +2 -2
- 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 +18 -24
- 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 +40 -31
- package/Mesher/Models/Nodes/Ruled/QuadVoxelGeometryNode.js +2 -2
- package/Mesher/Models/Nodes/Ruleless/RulelessBoxVoxelGeometryNode.js +2 -2
- package/Mesher/Models/Nodes/Ruleless/RulelessQuadVoxelGeometryNode.js +2 -2
- 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 +6 -6
- package/Mesher/Models/VoxelConstructor.js +8 -8
- package/Mesher/Models/VoxelGeometryBuilderCacheSpace.d.ts +3 -5
- package/Mesher/Models/VoxelGeometryBuilderCacheSpace.js +8 -32
- package/Mesher/{Tools/VoxelMesherDataTool.d.ts → Models/VoxelModelBuilder.d.ts} +4 -5
- package/Mesher/{Tools/VoxelMesherDataTool.js → Models/VoxelModelBuilder.js} +5 -8
- package/Mesher/Types/Mesher.types.d.ts +1 -0
- package/Models/Defaults/CubeVoxelGeometry.js +4 -0
- package/Models/Defaults/CubeVoxelModels.js +360 -383
- package/Models/Defaults/LiquidVoxelModel.js +5 -5
- package/Models/Defaults/PanelVoxelModels.js +442 -468
- package/Models/Defaults/StairVoxelModel.js +582 -597
- package/Models/Examples.js +490 -498
- package/Models/Rules/Classes/VoxelRulesModel.d.ts +1 -1
- package/Models/Rules/Classes/VoxelRulesModel.js +3 -3
- package/Models/Rules/Functions/BuildFinalInputs.d.ts +1 -1
- package/Models/Rules/Functions/BuildFinalInputs.js +21 -19
- 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 +17 -8
- package/Renderer/Classes/DVESectionMeshes.d.ts +2 -3
- package/Renderer/Classes/SectorMesh.d.ts +3 -4
- package/Renderer/Classes/SectorMesh.js +6 -11
- package/Renderer/InitTasks.js +1 -10
- package/Renderer/MeshManager.d.ts +1 -1
- package/Renderer/MeshManager.js +26 -25
- package/Renderer/MeshRegister.d.ts +5 -5
- package/Renderer/MeshRegister.js +4 -3
- package/Settings/EngineSettings.d.ts +2 -1
- package/Settings/EngineSettings.js +6 -5
- package/Settings/EngineSettings.types.d.ts +24 -39
- package/Settings/EngineSettings.types.js +22 -29
- package/Tasks/Logic/InitTasks.d.ts +1 -0
- package/Tasks/Logic/InitTasks.js +10 -0
- package/Tasks/Logic/VoxelLogicUpdate.d.ts +3 -0
- package/Tasks/Logic/VoxelLogicUpdate.js +71 -0
- package/Tasks/Propagation/Explosion/ExplosionManager.d.ts +2 -2
- package/Tasks/Propagation/Explosion/ExplosionManager.js +1 -2
- package/Tasks/Propagation/Flow/FlowManager.d.ts +4 -4
- package/Tasks/Propagation/Flow/FlowRemove.d.ts +2 -2
- package/Tasks/Propagation/Flow/FlowUpdate.d.ts +2 -2
- package/Tasks/Propagation/Flow/WorldFlow.d.ts +2 -2
- package/Tasks/Propagation/Illumanation/RGBUpdate.d.ts +3 -3
- package/Tasks/Propagation/Illumanation/SunUpdate.d.ts +3 -3
- package/Tasks/Propagation/Illumanation/WorldRGB.d.ts +2 -2
- package/Tasks/Propagation/Illumanation/WorldSun.d.ts +2 -2
- package/Tasks/Propagation/Illumanation/WorldSun.js +8 -15
- package/Tasks/Propagation/InitTasks.js +4 -4
- package/Tasks/Propagation/Power/PowerUpdate.d.ts +3 -0
- package/Tasks/Propagation/Power/PowerUpdate.js +80 -0
- package/Tasks/Tasks.types.d.ts +2 -2
- package/Tasks/TasksIds.d.ts +2 -1
- package/Tasks/TasksIds.js +1 -0
- package/Tasks/Update/Common.d.ts +3 -0
- package/Tasks/Update/Common.js +41 -0
- package/Tasks/Update/EreaseUpdate.d.ts +3 -0
- package/Tasks/Update/EreaseUpdate.js +66 -0
- package/Tasks/Update/InitTasks.d.ts +2 -2
- package/Tasks/Update/InitTasks.js +3 -1
- package/Tasks/Update/PaintUpdate.d.ts +3 -0
- package/Tasks/Update/PaintUpdate.js +89 -0
- package/Tasks/Update/VoxelUpdate.d.ts +2 -5
- package/Tasks/Update/VoxelUpdate.js +7 -143
- package/Tasks/{Update/UpdateTask.d.ts → VoxelUpdateTask.d.ts} +16 -6
- package/Tasks/{Update/UpdateTask.js → VoxelUpdateTask.js} +44 -5
- package/Tasks/WorldGeneration/WorldGenBrush.d.ts +3 -3
- package/Tasks/WorldGeneration/WorldGenBrush.js +3 -3
- package/Tasks/WorldGeneration/WorldGenRegister.d.ts +1 -1
- package/Templates/Cursor/TemplateCursor.d.ts +2 -2
- package/Templates/Cursor/TemplateCursor.js +1 -2
- package/Templates/Functions/CreateTemplate.d.ts +1 -1
- 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/AdvancedBrushTool.js +1 -1
- package/Tools/Brush/Brush.d.ts +3 -3
- package/Tools/Brush/Brush.js +40 -8
- package/Tools/Tasks/TasksTool.d.ts +1 -0
- package/Tools/Tasks/TasksTool.js +2 -0
- package/Util/Binary/BinaryArrays.d.ts +6 -0
- package/Util/Binary/BinaryArrays.js +25 -0
- package/Util/Binary/BinaryBuffer.d.ts +35 -0
- package/Util/Binary/BinaryBuffer.js +136 -0
- package/Util/Binary/{BitArray.d.ts → BinaryFunctions.d.ts} +1 -2
- package/Util/Binary/BinaryFunctions.js +11 -0
- package/{Mesher/Tools/VoxelMeshBVHBuilder.d.ts → Util/Binary/BinaryTree.d.ts} +1 -33
- package/Util/Binary/BinaryTree.js +104 -0
- package/Voxels/Cursor/DataCursor.interface.d.ts +5 -0
- package/Voxels/Cursor/VoxelCursor.interface.d.ts +8 -3
- package/Voxels/Cursor/VoxelCursor.interface.js +54 -13
- package/Voxels/Cursor/VoxelLightData.js +1 -1
- package/Voxels/Data/VoxelPalettesRegister.d.ts +0 -5
- package/Voxels/Data/VoxelPalettesRegister.js +0 -9
- package/Voxels/Data/VoxelTag.types.d.ts +17 -2
- package/Voxels/Data/VoxelTag.types.js +6 -1
- package/Voxels/Data/VoxelTagsRegister.js +12 -7
- package/Voxels/Functions/BuildStateData.d.ts +6 -6
- package/Voxels/Functions/BuildStateData.js +37 -37
- package/Voxels/Functions/BuildTagAndPaletteData.js +6 -3
- package/Voxels/Indexes/VoxelIndex.d.ts +2 -2
- package/Voxels/Indexes/VoxelIndex.js +16 -18
- package/Voxels/InitVoxelData.js +24 -21
- package/Voxels/Logic/Classes/Default/Types/VoxelPoweredLogicType.d.ts +5 -0
- package/Voxels/Logic/Classes/Default/Types/VoxelPoweredLogicType.js +6 -0
- package/Voxels/Logic/Classes/VoxelLogic.d.ts +11 -0
- package/Voxels/Logic/Classes/VoxelLogic.js +49 -0
- package/Voxels/Logic/Classes/VoxelLogicType.d.ts +4 -0
- package/Voxels/Logic/Classes/VoxelLogicType.js +2 -0
- package/Voxels/Logic/VoxelLogic.types.d.ts +23 -0
- package/Voxels/Logic/VoxelLogic.types.js +1 -0
- package/Voxels/Logic/VoxelLogicRegister.d.ts +9 -0
- package/Voxels/Logic/VoxelLogicRegister.js +15 -0
- package/Voxels/State/Schema/StateSchema.d.ts +1 -1
- package/Voxels/State/SchemaRegister.js +10 -5
- package/Voxels/State/State.types.d.ts +1 -1
- package/Voxels/State/StateTreeReader.d.ts +1 -1
- package/Voxels/State/StateTreeReader.js +2 -3
- package/Voxels/Types/Voxel.types.d.ts +21 -0
- package/Voxels/Types/Voxel.types.js +6 -2
- package/Voxels/Types/VoxelModelCompiledData.types.d.ts +6 -4
- package/World/Archive/Archive.types.d.ts +65 -42
- package/World/Archive/Classes/ArchiveClasses.d.ts +66 -0
- package/World/Archive/Classes/ArchiveClasses.js +78 -0
- package/World/Archive/Classes/ImportedSection.d.ts +40 -0
- package/World/Archive/Classes/ImportedSection.js +307 -0
- package/World/Archive/Classes/ImportedSector.d.ts +23 -0
- package/World/Archive/Classes/ImportedSector.js +97 -0
- package/World/Archive/Functions/ArchiveArea.d.ts +1 -1
- package/World/Archive/Functions/ArchiveArea.js +49 -54
- package/World/Archive/Functions/ArchiveSector.js +373 -282
- package/World/Archive/Functions/CreateArchivedSection.d.ts +3 -0
- package/World/Archive/Functions/CreateArchivedSection.js +207 -0
- package/World/Archive/Functions/ImportSector.d.ts +2 -4
- package/World/Archive/Functions/ImportSector.js +50 -220
- package/World/Archive/Functions/RemoveDuplicates.d.ts +3 -0
- package/World/Archive/Functions/RemoveDuplicates.js +92 -0
- package/World/Archive/Functions/Shared.d.ts +6 -0
- package/World/Archive/Functions/Shared.js +50 -0
- package/World/Archive/InitTasks.js +37 -23
- package/World/Cursor/SectionCursor.d.ts +3 -3
- package/World/Cursor/SectionCursor.js +2 -3
- package/World/Cursor/SectorCursor.d.ts +3 -3
- package/World/Cursor/SectorCursor.js +1 -2
- package/World/Cursor/WorldCursor.d.ts +6 -5
- package/World/Cursor/WorldCursor.js +17 -15
- package/World/Cursor/WorldVoxelCursor.d.ts +0 -4
- package/World/Cursor/WorldVoxelCursor.js +24 -14
- package/World/Dimension/Dimension.d.ts +4 -1
- package/World/Dimension/Dimension.js +8 -1
- package/World/InitTasks.d.ts +1 -1
- package/World/Lock/WorldLock.d.ts +1 -1
- package/World/Section/Section.d.ts +27 -18
- package/World/Section/Section.js +125 -21
- package/World/Section/SectionState.d.ts +12 -0
- package/World/Section/SectionState.js +13 -0
- package/World/Sector/Sector.d.ts +20 -6
- package/World/Sector/Sector.js +100 -17
- package/World/Sector/SectorHeightMap.js +2 -2
- package/World/Sector/SectorState.d.ts +16 -7
- package/World/Sector/SectorState.js +29 -15
- package/World/Types/WorldData.types.d.ts +2 -7
- package/World/Types/WorldStorage.interface.js +1 -0
- package/World/WorldRegister.d.ts +13 -9
- package/World/WorldRegister.js +24 -9
- package/World/WorldSpaces.d.ts +4 -0
- package/World/WorldSpaces.js +25 -12
- package/{Tasks/IWG → WorldSimulation}/Internal/Classes/DimensionSegment.d.ts +2 -2
- package/{Tasks/IWG → WorldSimulation}/Internal/Classes/Generator.d.ts +10 -3
- package/{Tasks/IWG → WorldSimulation}/Internal/Classes/Generator.js +19 -3
- package/WorldSimulation/Internal/Classes/Queues/BuildQueue.d.ts +5 -0
- package/WorldSimulation/Internal/Classes/Queues/BuildQueue.js +6 -0
- package/WorldSimulation/Internal/Classes/Queues/LogiccQueue.d.ts +5 -0
- package/WorldSimulation/Internal/Classes/Queues/LogiccQueue.js +6 -0
- package/{Tasks/IWG → WorldSimulation}/Internal/Classes/SectorVisistedMap.js +1 -1
- package/WorldSimulation/Internal/Classes/TickQueue.d.ts +12 -0
- package/WorldSimulation/Internal/Classes/TickQueue.js +58 -0
- package/WorldSimulation/Internal/Classes/WorldSimulationTaskBase.d.ts +15 -0
- package/{Tasks/IWG/Internal/Classes/IWGTaskBase.js → WorldSimulation/Internal/Classes/WorldSimulationTaskBase.js} +8 -8
- package/{Tasks/IWG → WorldSimulation}/Internal/Functions/cullSectors.js +9 -9
- package/{Tasks/IWG → WorldSimulation}/Internal/Functions/getSectorState.d.ts +1 -1
- package/{Tasks/IWG → WorldSimulation}/Internal/Functions/getSectorState.js +4 -4
- package/WorldSimulation/Internal/Functions/runTickUpdate.d.ts +2 -0
- package/{Tasks/IWG/Internal/Functions/runBuildUpdate.js → WorldSimulation/Internal/Functions/runTickUpdate.js} +38 -9
- package/{Tasks/IWG → WorldSimulation}/Internal/Functions/runWorldUpdate.js +13 -13
- package/{Tasks/IWG → WorldSimulation}/Internal/TaskRegister.d.ts +2 -2
- package/{Tasks/IWG → WorldSimulation}/Internal/TaskRegister.js +1 -1
- package/WorldSimulation/Internal/WorldSimulationDimensions.d.ts +6 -0
- package/{Tasks/IWG/Internal/IWGDimensions.js → WorldSimulation/Internal/WorldSimulationDimensions.js} +1 -1
- package/WorldSimulation/Internal/WorldSimulationTasks.d.ts +30 -0
- package/{Tasks/IWG/Internal/IWGTasks.js → WorldSimulation/Internal/WorldSimulationTasks.js} +14 -24
- package/WorldSimulation/Internal/WorldSimulationTools.d.ts +8 -0
- package/{Tasks/IWG/Internal/IWGTools.js → WorldSimulation/Internal/WorldSimulationTools.js} +1 -1
- package/{Tasks/IWG → WorldSimulation}/Procedures/InitalLoad.d.ts +1 -1
- package/{Tasks/IWG → WorldSimulation}/Procedures/InitalLoad.js +11 -11
- package/{Tasks/IWG → WorldSimulation}/Procedures/SaveAllSectors.js +7 -5
- package/{Tasks/IWG/IWG.d.ts → WorldSimulation/WorldSimulation.d.ts} +6 -5
- package/{Tasks/IWG/IWG.js → WorldSimulation/WorldSimulation.js} +29 -23
- package/{Tasks/IWG → WorldSimulation}/index.d.ts +1 -1
- package/{Tasks/IWG → WorldSimulation}/index.js +1 -1
- 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/Mesher/Tools/VoxelMeshBVHBuilder.js +0 -216
- package/Models/Rules/VoxelModelManager.js +0 -82
- package/Tasks/IWG/Internal/Classes/IWGTaskBase.d.ts +0 -15
- package/Tasks/IWG/Internal/Functions/runBuildUpdate.d.ts +0 -2
- package/Tasks/IWG/Internal/IWGDimensions.d.ts +0 -6
- package/Tasks/IWG/Internal/IWGTasks.d.ts +0 -34
- package/Tasks/IWG/Internal/IWGTools.d.ts +0 -8
- 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/Geomtry/{Buffers.d.ts → VoxelMeshBuffers.d.ts} +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
- /package/{Tasks/IWG → WorldSimulation}/Internal/Classes/DimensionSegment.js +0 -0
- /package/{Tasks/IWG → WorldSimulation}/Internal/Classes/SectorState.d.ts +0 -0
- /package/{Tasks/IWG → WorldSimulation}/Internal/Classes/SectorState.js +0 -0
- /package/{Tasks/IWG → WorldSimulation}/Internal/Classes/SectorVisistedMap.d.ts +0 -0
- /package/{Tasks/IWG → WorldSimulation}/Internal/Functions/cullSectors.d.ts +0 -0
- /package/{Tasks/IWG → WorldSimulation}/Internal/Functions/runWorldUpdate.d.ts +0 -0
- /package/{Tasks/IWG → WorldSimulation}/Procedures/SaveAllSectors.d.ts +0 -0
|
@@ -68,22 +68,22 @@ export class QuadVertexData {
|
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
70
|
clone() {
|
|
71
|
-
return new QuadVertexData(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
71
|
+
return new QuadVertexData([
|
|
72
|
+
structuredClone(this.vertices[QuadVerticies.TopRight]),
|
|
73
|
+
structuredClone(this.vertices[QuadVerticies.TopLeft]),
|
|
74
|
+
structuredClone(this.vertices[QuadVerticies.BottomLeft]),
|
|
75
|
+
structuredClone(this.vertices[QuadVerticies.BottomRight]),
|
|
76
|
+
]);
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
export class QuadVec3ArrayVertexData extends QuadVertexData {
|
|
80
80
|
vertices;
|
|
81
|
-
constructor(vertices =
|
|
82
|
-
[
|
|
83
|
-
[
|
|
84
|
-
[
|
|
85
|
-
[
|
|
86
|
-
|
|
81
|
+
constructor(vertices = [
|
|
82
|
+
[0, 0, 0],
|
|
83
|
+
[0, 0, 0],
|
|
84
|
+
[0, 0, 0],
|
|
85
|
+
[0, 0, 0],
|
|
86
|
+
]) {
|
|
87
87
|
super(vertices);
|
|
88
88
|
this.vertices = vertices;
|
|
89
89
|
}
|
|
@@ -124,24 +124,22 @@ export class QuadVec3ArrayVertexData extends QuadVertexData {
|
|
|
124
124
|
Vector3Like.EqualsArray(this.vertices[QuadVerticies.BottomRight], v1));
|
|
125
125
|
}
|
|
126
126
|
clone() {
|
|
127
|
-
return new QuadVec3ArrayVertexData(
|
|
128
|
-
[
|
|
129
|
-
[
|
|
130
|
-
[
|
|
131
|
-
[QuadVerticies.BottomRight]
|
|
132
|
-
|
|
133
|
-
],
|
|
134
|
-
});
|
|
127
|
+
return new QuadVec3ArrayVertexData([
|
|
128
|
+
[...this.vertices[QuadVerticies.TopRight]],
|
|
129
|
+
[...this.vertices[QuadVerticies.TopLeft]],
|
|
130
|
+
[...this.vertices[QuadVerticies.BottomLeft]],
|
|
131
|
+
[...this.vertices[QuadVerticies.BottomRight]],
|
|
132
|
+
]);
|
|
135
133
|
}
|
|
136
134
|
}
|
|
137
135
|
export class QuadVector3VertexData extends QuadVertexData {
|
|
138
136
|
vertices;
|
|
139
|
-
constructor(vertices =
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
137
|
+
constructor(vertices = [
|
|
138
|
+
Vector3Like.Create(),
|
|
139
|
+
Vector3Like.Create(),
|
|
140
|
+
Vector3Like.Create(),
|
|
141
|
+
Vector3Like.Create(),
|
|
142
|
+
]) {
|
|
145
143
|
super(vertices);
|
|
146
144
|
this.vertices = vertices;
|
|
147
145
|
}
|
|
@@ -182,22 +180,22 @@ export class QuadVector3VertexData extends QuadVertexData {
|
|
|
182
180
|
Vector3Like.Equals(this.vertices[QuadVerticies.BottomRight], v1));
|
|
183
181
|
}
|
|
184
182
|
clone() {
|
|
185
|
-
return new QuadVector3VertexData(
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
183
|
+
return new QuadVector3VertexData([
|
|
184
|
+
Vector3Like.Clone(this.vertices[QuadVerticies.TopRight]),
|
|
185
|
+
Vector3Like.Clone(this.vertices[QuadVerticies.TopLeft]),
|
|
186
|
+
Vector3Like.Clone(this.vertices[QuadVerticies.BottomLeft]),
|
|
187
|
+
Vector3Like.Clone(this.vertices[QuadVerticies.BottomRight]),
|
|
188
|
+
]);
|
|
191
189
|
}
|
|
192
190
|
}
|
|
193
191
|
export class QuadVector2VertexData extends QuadVertexData {
|
|
194
192
|
vertices;
|
|
195
|
-
constructor(vertices =
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
193
|
+
constructor(vertices = [
|
|
194
|
+
Vector2Like.Create(),
|
|
195
|
+
Vector2Like.Create(),
|
|
196
|
+
Vector2Like.Create(),
|
|
197
|
+
Vector2Like.Create(),
|
|
198
|
+
]) {
|
|
201
199
|
super(vertices);
|
|
202
200
|
this.vertices = vertices;
|
|
203
201
|
}
|
|
@@ -238,22 +236,17 @@ export class QuadVector2VertexData extends QuadVertexData {
|
|
|
238
236
|
Vector2Like.Equals(this.vertices[QuadVerticies.BottomRight], v1));
|
|
239
237
|
}
|
|
240
238
|
clone() {
|
|
241
|
-
return new QuadVector2VertexData(
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
239
|
+
return new QuadVector2VertexData([
|
|
240
|
+
Vector2Like.Clone(this.vertices[QuadVerticies.TopRight]),
|
|
241
|
+
Vector2Like.Clone(this.vertices[QuadVerticies.TopLeft]),
|
|
242
|
+
Vector2Like.Clone(this.vertices[QuadVerticies.BottomLeft]),
|
|
243
|
+
Vector2Like.Clone(this.vertices[QuadVerticies.BottomRight]),
|
|
244
|
+
]);
|
|
247
245
|
}
|
|
248
246
|
}
|
|
249
247
|
export class QuadScalarVertexData extends QuadVertexData {
|
|
250
248
|
vertices;
|
|
251
|
-
constructor(vertices = {
|
|
252
|
-
[QuadVerticies.TopRight]: 0,
|
|
253
|
-
[QuadVerticies.TopLeft]: 0,
|
|
254
|
-
[QuadVerticies.BottomLeft]: 0,
|
|
255
|
-
[QuadVerticies.BottomRight]: 0,
|
|
256
|
-
}) {
|
|
249
|
+
constructor(vertices = [0, 0, 0, 0]) {
|
|
257
250
|
super(vertices);
|
|
258
251
|
this.vertices = vertices;
|
|
259
252
|
}
|
|
@@ -339,11 +332,11 @@ export class QuadScalarVertexData extends QuadVertexData {
|
|
|
339
332
|
return true;
|
|
340
333
|
}
|
|
341
334
|
clone() {
|
|
342
|
-
return new QuadScalarVertexData(
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
335
|
+
return new QuadScalarVertexData([
|
|
336
|
+
this.vertices[QuadVerticies.TopRight],
|
|
337
|
+
this.vertices[QuadVerticies.TopLeft],
|
|
338
|
+
this.vertices[QuadVerticies.BottomLeft],
|
|
339
|
+
this.vertices[QuadVerticies.BottomRight],
|
|
340
|
+
]);
|
|
348
341
|
}
|
|
349
342
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Vector3Like } from "@amodx/math";
|
|
2
|
-
import {
|
|
2
|
+
import { VoxelModelBuilder } from "../Models/VoxelModelBuilder";
|
|
3
3
|
import { Quad } from "./Primitives/Quad";
|
|
4
4
|
export declare class VoxelGeometryBuilder {
|
|
5
|
-
static addQuad(tool: VoxelMesherDataTool, origin: Vector3Like, quad: Quad): void;
|
|
6
5
|
}
|
|
6
|
+
export declare function addVoxelQuad(tool: VoxelModelBuilder, origin: Vector3Like, quad: Quad): void;
|
|
@@ -1,208 +1,129 @@
|
|
|
1
|
-
import { VoxelShaderData } from "
|
|
1
|
+
import { VoxelShaderData } from "./VoxelShaderData";
|
|
2
2
|
import { QuadVerticies } from "./Geometry.types";
|
|
3
|
-
import { VoxelMeshVertexConstants, VoxelMeshVertexStructCursor, } from "
|
|
3
|
+
import { VoxelMeshVertexConstants, VoxelMeshVertexStructCursor, } from "./VoxelMeshVertexStructCursor";
|
|
4
4
|
const empty = [];
|
|
5
5
|
const structCursor = new VoxelMeshVertexStructCursor();
|
|
6
6
|
export class VoxelGeometryBuilder {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const bottomLeftNor = quad.normals.vertices[2];
|
|
97
|
-
const bottomRightNor = quad.normals.vertices[3];
|
|
98
|
-
const topRightVoxelData = VoxelShaderData.createAttribute(worldLight.vertices[QuadVerticies.TopRight], worldAO.vertices[QuadVerticies.TopRight], animData.vertices[QuadVerticies.TopRight]);
|
|
99
|
-
const topLeftVoxelData = VoxelShaderData.createAttribute(worldLight.vertices[QuadVerticies.TopLeft], worldAO.vertices[QuadVerticies.TopLeft], animData.vertices[QuadVerticies.TopLeft]);
|
|
100
|
-
const bottomLeftVoxelData = VoxelShaderData.createAttribute(worldLight.vertices[QuadVerticies.BottomLeft], worldAO.vertices[QuadVerticies.BottomLeft], animData.vertices[QuadVerticies.BottomLeft]);
|
|
101
|
-
const bottomRightVoxelData = VoxelShaderData.createAttribute(worldLight.vertices[QuadVerticies.BottomRight], worldAO.vertices[QuadVerticies.BottomRight], animData.vertices[QuadVerticies.BottomRight]);
|
|
102
|
-
const indices = tool.mesh.indices;
|
|
103
|
-
let indIndex = tool.mesh.indicieCount;
|
|
104
|
-
let sides = quad.doubleSided ? 2 : 1;
|
|
105
|
-
const flip = quad.flip;
|
|
106
|
-
let orientation = quad.orientation;
|
|
107
|
-
while (sides--) {
|
|
108
|
-
const baseIndex = tool.mesh.vertexCount;
|
|
109
|
-
if (!flip) {
|
|
110
|
-
tool.mesh.buffer.setIndex(baseIndex);
|
|
111
|
-
structCursor.data = tool.mesh.buffer.currentArray;
|
|
112
|
-
structCursor.index = tool.mesh.buffer.curentIndex;
|
|
113
|
-
addVertex(tool.mesh.buffer.curentIndex, tool.mesh.buffer.currentArray, origin, topRightPos, topRightNor, quad.uvs.vertices[QuadVerticies.TopRight], topRightVoxelData, texture, overlayTextures);
|
|
114
|
-
tool.mesh.buffer.setIndex(baseIndex + 1);
|
|
115
|
-
structCursor.data = tool.mesh.buffer.currentArray;
|
|
116
|
-
structCursor.index = tool.mesh.buffer.curentIndex;
|
|
117
|
-
addVertex(tool.mesh.buffer.curentIndex, tool.mesh.buffer.currentArray, origin, topLeftPos, topLeftNor, quad.uvs.vertices[QuadVerticies.TopLeft], topLeftVoxelData, texture, overlayTextures);
|
|
118
|
-
tool.mesh.buffer.setIndex(baseIndex + 2);
|
|
119
|
-
structCursor.data = tool.mesh.buffer.currentArray;
|
|
120
|
-
structCursor.index = tool.mesh.buffer.curentIndex;
|
|
121
|
-
addVertex(tool.mesh.buffer.curentIndex, tool.mesh.buffer.currentArray, origin, bottomLeftPos, bottomLeftNor, quad.uvs.vertices[QuadVerticies.BottomLeft], bottomLeftVoxelData, texture, overlayTextures);
|
|
122
|
-
tool.mesh.buffer.setIndex(baseIndex + 3);
|
|
123
|
-
structCursor.data = tool.mesh.buffer.currentArray;
|
|
124
|
-
structCursor.index = tool.mesh.buffer.curentIndex;
|
|
125
|
-
addVertex(tool.mesh.buffer.curentIndex, tool.mesh.buffer.currentArray, origin, bottomRightPos, bottomRightNor, quad.uvs.vertices[QuadVerticies.BottomRight], bottomRightVoxelData, texture, overlayTextures);
|
|
126
|
-
}
|
|
127
|
-
if (flip) {
|
|
128
|
-
tool.mesh.buffer.setIndex(baseIndex);
|
|
129
|
-
structCursor.data = tool.mesh.buffer.currentArray;
|
|
130
|
-
structCursor.index = tool.mesh.buffer.curentIndex;
|
|
131
|
-
addVertex(tool.mesh.buffer.curentIndex, tool.mesh.buffer.currentArray, origin, topLeftPos, topLeftNor, quad.uvs.vertices[QuadVerticies.TopLeft], topLeftVoxelData, texture, overlayTextures);
|
|
132
|
-
tool.mesh.buffer.setIndex(baseIndex + 1);
|
|
133
|
-
structCursor.data = tool.mesh.buffer.currentArray;
|
|
134
|
-
structCursor.index = tool.mesh.buffer.curentIndex;
|
|
135
|
-
addVertex(tool.mesh.buffer.curentIndex, tool.mesh.buffer.currentArray, origin, topRightPos, topRightNor, quad.uvs.vertices[QuadVerticies.TopRight], topRightVoxelData, texture, overlayTextures);
|
|
136
|
-
tool.mesh.buffer.setIndex(baseIndex + 2);
|
|
137
|
-
structCursor.data = tool.mesh.buffer.currentArray;
|
|
138
|
-
structCursor.index = tool.mesh.buffer.curentIndex;
|
|
139
|
-
addVertex(tool.mesh.buffer.curentIndex, tool.mesh.buffer.currentArray, origin, bottomRightPos, bottomRightNor, quad.uvs.vertices[QuadVerticies.BottomRight], bottomRightVoxelData, texture, overlayTextures);
|
|
140
|
-
tool.mesh.buffer.setIndex(baseIndex + 3);
|
|
141
|
-
structCursor.data = tool.mesh.buffer.currentArray;
|
|
142
|
-
structCursor.index = tool.mesh.buffer.curentIndex;
|
|
143
|
-
addVertex(tool.mesh.buffer.curentIndex, tool.mesh.buffer.currentArray, origin, bottomLeftPos, bottomLeftNor, quad.uvs.vertices[QuadVerticies.BottomLeft], bottomLeftVoxelData, texture, overlayTextures);
|
|
144
|
-
}
|
|
145
|
-
if (!orientation && !flip) {
|
|
146
|
-
indices.setIndex(indIndex).currentArray[indices.curentIndex] =
|
|
147
|
-
baseIndex;
|
|
148
|
-
indices.setIndex(indIndex + 1).currentArray[indices.curentIndex] =
|
|
149
|
-
baseIndex + 1;
|
|
150
|
-
indices.setIndex(indIndex + 2).currentArray[indices.curentIndex] =
|
|
151
|
-
baseIndex + 2;
|
|
152
|
-
indices.setIndex(indIndex + 3).currentArray[indices.curentIndex] =
|
|
153
|
-
baseIndex + 2;
|
|
154
|
-
indices.setIndex(indIndex + 4).currentArray[indices.curentIndex] =
|
|
155
|
-
baseIndex + 3;
|
|
156
|
-
indices.setIndex(indIndex + 5).currentArray[indices.curentIndex] =
|
|
157
|
-
baseIndex;
|
|
158
|
-
}
|
|
159
|
-
else if (!orientation && flip) {
|
|
160
|
-
indices.setIndex(indIndex).currentArray[indices.curentIndex] =
|
|
161
|
-
baseIndex;
|
|
162
|
-
indices.setIndex(indIndex + 1).currentArray[indices.curentIndex] =
|
|
163
|
-
baseIndex + 3;
|
|
164
|
-
indices.setIndex(indIndex + 2).currentArray[indices.curentIndex] =
|
|
165
|
-
baseIndex + 2;
|
|
166
|
-
indices.setIndex(indIndex + 3).currentArray[indices.curentIndex] =
|
|
167
|
-
baseIndex + 2;
|
|
168
|
-
indices.setIndex(indIndex + 4).currentArray[indices.curentIndex] =
|
|
169
|
-
baseIndex + 1;
|
|
170
|
-
indices.setIndex(indIndex + 5).currentArray[indices.curentIndex] =
|
|
171
|
-
baseIndex;
|
|
172
|
-
}
|
|
173
|
-
if (orientation && !flip) {
|
|
174
|
-
indices.setIndex(indIndex).currentArray[indices.curentIndex] =
|
|
175
|
-
baseIndex;
|
|
176
|
-
indices.setIndex(indIndex + 1).currentArray[indices.curentIndex] =
|
|
177
|
-
baseIndex + 3;
|
|
178
|
-
indices.setIndex(indIndex + 2).currentArray[indices.curentIndex] =
|
|
179
|
-
baseIndex + 2;
|
|
180
|
-
indices.setIndex(indIndex + 3).currentArray[indices.curentIndex] =
|
|
181
|
-
baseIndex + 2;
|
|
182
|
-
indices.setIndex(indIndex + 4).currentArray[indices.curentIndex] =
|
|
183
|
-
baseIndex + 1;
|
|
184
|
-
indices.setIndex(indIndex + 5).currentArray[indices.curentIndex] =
|
|
185
|
-
baseIndex;
|
|
186
|
-
}
|
|
187
|
-
else if (orientation && flip) {
|
|
188
|
-
indices.setIndex(indIndex).currentArray[indices.curentIndex] =
|
|
189
|
-
baseIndex;
|
|
190
|
-
indices.setIndex(indIndex + 1).currentArray[indices.curentIndex] =
|
|
191
|
-
baseIndex + 1;
|
|
192
|
-
indices.setIndex(indIndex + 2).currentArray[indices.curentIndex] =
|
|
193
|
-
baseIndex + 2;
|
|
194
|
-
indices.setIndex(indIndex + 3).currentArray[indices.curentIndex] =
|
|
195
|
-
baseIndex + 2;
|
|
196
|
-
indices.setIndex(indIndex + 4).currentArray[indices.curentIndex] =
|
|
197
|
-
baseIndex + 3;
|
|
198
|
-
indices.setIndex(indIndex + 5).currentArray[indices.curentIndex] =
|
|
199
|
-
baseIndex;
|
|
200
|
-
}
|
|
201
|
-
tool.mesh.addVerticies(4, 6);
|
|
7
|
+
}
|
|
8
|
+
export function addVoxelQuad(tool, origin, quad) {
|
|
9
|
+
if (!tool.mesh)
|
|
10
|
+
return;
|
|
11
|
+
const worldLight = tool.vars.light;
|
|
12
|
+
const worldAO = tool.vars.ao;
|
|
13
|
+
const animData = tool.vars.animation;
|
|
14
|
+
const texture = tool.vars.textureIndex;
|
|
15
|
+
const overlayTextures = tool.vars.overlayTextures;
|
|
16
|
+
const topRightPos = quad.positions.vertices[0];
|
|
17
|
+
const topLeftPos = quad.positions.vertices[1];
|
|
18
|
+
const bottomLeftPos = quad.positions.vertices[2];
|
|
19
|
+
const bottomRightPos = quad.positions.vertices[3];
|
|
20
|
+
const topRightNor = quad.normals.vertices[0];
|
|
21
|
+
const topLeftNor = quad.normals.vertices[1];
|
|
22
|
+
const bottomLeftNor = quad.normals.vertices[2];
|
|
23
|
+
const bottomRightNor = quad.normals.vertices[3];
|
|
24
|
+
const topRightVoxelData = VoxelShaderData.createAttribute(worldLight.vertices[QuadVerticies.TopRight], worldAO.vertices[QuadVerticies.TopRight], animData.vertices[QuadVerticies.TopRight]);
|
|
25
|
+
const topLeftVoxelData = VoxelShaderData.createAttribute(worldLight.vertices[QuadVerticies.TopLeft], worldAO.vertices[QuadVerticies.TopLeft], animData.vertices[QuadVerticies.TopLeft]);
|
|
26
|
+
const bottomLeftVoxelData = VoxelShaderData.createAttribute(worldLight.vertices[QuadVerticies.BottomLeft], worldAO.vertices[QuadVerticies.BottomLeft], animData.vertices[QuadVerticies.BottomLeft]);
|
|
27
|
+
const bottomRightVoxelData = VoxelShaderData.createAttribute(worldLight.vertices[QuadVerticies.BottomRight], worldAO.vertices[QuadVerticies.BottomRight], animData.vertices[QuadVerticies.BottomRight]);
|
|
28
|
+
const indices = tool.mesh.indices;
|
|
29
|
+
let indIndex = tool.mesh.indicieCount;
|
|
30
|
+
let sides = quad.doubleSided ? 2 : 1;
|
|
31
|
+
const flip = quad.flip;
|
|
32
|
+
let orientation = quad.orientation;
|
|
33
|
+
while (sides--) {
|
|
34
|
+
const baseIndex = tool.mesh.vertexCount;
|
|
35
|
+
if (!flip) {
|
|
36
|
+
tool.mesh.buffer.setIndex(baseIndex);
|
|
37
|
+
structCursor.data = tool.mesh.buffer.currentArray;
|
|
38
|
+
structCursor.index = tool.mesh.buffer.curentIndex;
|
|
39
|
+
addVertex(tool.mesh.buffer.curentIndex, tool.mesh.buffer.currentArray, origin, topRightPos, topRightNor, quad.uvs.vertices[QuadVerticies.TopRight], topRightVoxelData, texture, overlayTextures);
|
|
40
|
+
tool.mesh.buffer.setIndex(baseIndex + 1);
|
|
41
|
+
structCursor.data = tool.mesh.buffer.currentArray;
|
|
42
|
+
structCursor.index = tool.mesh.buffer.curentIndex;
|
|
43
|
+
addVertex(tool.mesh.buffer.curentIndex, tool.mesh.buffer.currentArray, origin, topLeftPos, topLeftNor, quad.uvs.vertices[QuadVerticies.TopLeft], topLeftVoxelData, texture, overlayTextures);
|
|
44
|
+
tool.mesh.buffer.setIndex(baseIndex + 2);
|
|
45
|
+
structCursor.data = tool.mesh.buffer.currentArray;
|
|
46
|
+
structCursor.index = tool.mesh.buffer.curentIndex;
|
|
47
|
+
addVertex(tool.mesh.buffer.curentIndex, tool.mesh.buffer.currentArray, origin, bottomLeftPos, bottomLeftNor, quad.uvs.vertices[QuadVerticies.BottomLeft], bottomLeftVoxelData, texture, overlayTextures);
|
|
48
|
+
tool.mesh.buffer.setIndex(baseIndex + 3);
|
|
49
|
+
structCursor.data = tool.mesh.buffer.currentArray;
|
|
50
|
+
structCursor.index = tool.mesh.buffer.curentIndex;
|
|
51
|
+
addVertex(tool.mesh.buffer.curentIndex, tool.mesh.buffer.currentArray, origin, bottomRightPos, bottomRightNor, quad.uvs.vertices[QuadVerticies.BottomRight], bottomRightVoxelData, texture, overlayTextures);
|
|
52
|
+
}
|
|
53
|
+
if (flip) {
|
|
54
|
+
tool.mesh.buffer.setIndex(baseIndex);
|
|
55
|
+
structCursor.data = tool.mesh.buffer.currentArray;
|
|
56
|
+
structCursor.index = tool.mesh.buffer.curentIndex;
|
|
57
|
+
addVertex(tool.mesh.buffer.curentIndex, tool.mesh.buffer.currentArray, origin, topLeftPos, topLeftNor, quad.uvs.vertices[QuadVerticies.TopLeft], topLeftVoxelData, texture, overlayTextures);
|
|
58
|
+
tool.mesh.buffer.setIndex(baseIndex + 1);
|
|
59
|
+
structCursor.data = tool.mesh.buffer.currentArray;
|
|
60
|
+
structCursor.index = tool.mesh.buffer.curentIndex;
|
|
61
|
+
addVertex(tool.mesh.buffer.curentIndex, tool.mesh.buffer.currentArray, origin, topRightPos, topRightNor, quad.uvs.vertices[QuadVerticies.TopRight], topRightVoxelData, texture, overlayTextures);
|
|
62
|
+
tool.mesh.buffer.setIndex(baseIndex + 2);
|
|
63
|
+
structCursor.data = tool.mesh.buffer.currentArray;
|
|
64
|
+
structCursor.index = tool.mesh.buffer.curentIndex;
|
|
65
|
+
addVertex(tool.mesh.buffer.curentIndex, tool.mesh.buffer.currentArray, origin, bottomRightPos, bottomRightNor, quad.uvs.vertices[QuadVerticies.BottomRight], bottomRightVoxelData, texture, overlayTextures);
|
|
66
|
+
tool.mesh.buffer.setIndex(baseIndex + 3);
|
|
67
|
+
structCursor.data = tool.mesh.buffer.currentArray;
|
|
68
|
+
structCursor.index = tool.mesh.buffer.curentIndex;
|
|
69
|
+
addVertex(tool.mesh.buffer.curentIndex, tool.mesh.buffer.currentArray, origin, bottomLeftPos, bottomLeftNor, quad.uvs.vertices[QuadVerticies.BottomLeft], bottomLeftVoxelData, texture, overlayTextures);
|
|
70
|
+
}
|
|
71
|
+
if (!orientation && !flip) {
|
|
72
|
+
indices.setIndex(indIndex).currentArray[indices.curentIndex] = baseIndex;
|
|
73
|
+
indices.setIndex(indIndex + 1).currentArray[indices.curentIndex] =
|
|
74
|
+
baseIndex + 1;
|
|
75
|
+
indices.setIndex(indIndex + 2).currentArray[indices.curentIndex] =
|
|
76
|
+
baseIndex + 2;
|
|
77
|
+
indices.setIndex(indIndex + 3).currentArray[indices.curentIndex] =
|
|
78
|
+
baseIndex + 2;
|
|
79
|
+
indices.setIndex(indIndex + 4).currentArray[indices.curentIndex] =
|
|
80
|
+
baseIndex + 3;
|
|
81
|
+
indices.setIndex(indIndex + 5).currentArray[indices.curentIndex] =
|
|
82
|
+
baseIndex;
|
|
83
|
+
}
|
|
84
|
+
else if (!orientation && flip) {
|
|
85
|
+
indices.setIndex(indIndex).currentArray[indices.curentIndex] = baseIndex;
|
|
86
|
+
indices.setIndex(indIndex + 1).currentArray[indices.curentIndex] =
|
|
87
|
+
baseIndex + 3;
|
|
88
|
+
indices.setIndex(indIndex + 2).currentArray[indices.curentIndex] =
|
|
89
|
+
baseIndex + 2;
|
|
90
|
+
indices.setIndex(indIndex + 3).currentArray[indices.curentIndex] =
|
|
91
|
+
baseIndex + 2;
|
|
92
|
+
indices.setIndex(indIndex + 4).currentArray[indices.curentIndex] =
|
|
93
|
+
baseIndex + 1;
|
|
94
|
+
indices.setIndex(indIndex + 5).currentArray[indices.curentIndex] =
|
|
95
|
+
baseIndex;
|
|
202
96
|
}
|
|
97
|
+
if (orientation && !flip) {
|
|
98
|
+
indices.setIndex(indIndex).currentArray[indices.curentIndex] = baseIndex;
|
|
99
|
+
indices.setIndex(indIndex + 1).currentArray[indices.curentIndex] =
|
|
100
|
+
baseIndex + 3;
|
|
101
|
+
indices.setIndex(indIndex + 2).currentArray[indices.curentIndex] =
|
|
102
|
+
baseIndex + 2;
|
|
103
|
+
indices.setIndex(indIndex + 3).currentArray[indices.curentIndex] =
|
|
104
|
+
baseIndex + 2;
|
|
105
|
+
indices.setIndex(indIndex + 4).currentArray[indices.curentIndex] =
|
|
106
|
+
baseIndex + 1;
|
|
107
|
+
indices.setIndex(indIndex + 5).currentArray[indices.curentIndex] =
|
|
108
|
+
baseIndex;
|
|
109
|
+
}
|
|
110
|
+
else if (orientation && flip) {
|
|
111
|
+
indices.setIndex(indIndex).currentArray[indices.curentIndex] = baseIndex;
|
|
112
|
+
indices.setIndex(indIndex + 1).currentArray[indices.curentIndex] =
|
|
113
|
+
baseIndex + 1;
|
|
114
|
+
indices.setIndex(indIndex + 2).currentArray[indices.curentIndex] =
|
|
115
|
+
baseIndex + 2;
|
|
116
|
+
indices.setIndex(indIndex + 3).currentArray[indices.curentIndex] =
|
|
117
|
+
baseIndex + 2;
|
|
118
|
+
indices.setIndex(indIndex + 4).currentArray[indices.curentIndex] =
|
|
119
|
+
baseIndex + 3;
|
|
120
|
+
indices.setIndex(indIndex + 5).currentArray[indices.curentIndex] =
|
|
121
|
+
baseIndex;
|
|
122
|
+
}
|
|
123
|
+
tool.mesh.addVerticies(4, 6);
|
|
203
124
|
}
|
|
204
125
|
}
|
|
205
|
-
|
|
126
|
+
function addVertex(index, array, origin, position, normal, uvs, voxelData, texture, overlayTextures) {
|
|
206
127
|
index *= VoxelMeshVertexConstants.VertexFloatSize;
|
|
207
128
|
array[VoxelMeshVertexConstants.PositionOffset + index] =
|
|
208
129
|
position.x + origin.x;
|
|
@@ -222,4 +143,4 @@ const addVertex = (index, array, origin, position, normal, uvs, voxelData, textu
|
|
|
222
143
|
array[VoxelMeshVertexConstants.TextureIndexOffset + index + 2] =
|
|
223
144
|
VoxelShaderData.createTextureIndex(overlayTextures.w, 0);
|
|
224
145
|
array[VoxelMeshVertexConstants.VoxelDataOFfset + index] = voxelData;
|
|
225
|
-
}
|
|
146
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Vector3Like } from "@amodx/math";
|
|
2
|
-
import { VoxelVertexBuffer, VoxelIndiceBuffer } from "./
|
|
3
|
-
import { VoxelMeshVertexStructCursor } from "
|
|
2
|
+
import { VoxelVertexBuffer, VoxelIndiceBuffer } from "./VoxelMeshBuffers";
|
|
3
|
+
import { VoxelMeshVertexStructCursor } from "./VoxelMeshVertexStructCursor";
|
|
4
4
|
export class VoxelMesh {
|
|
5
5
|
indicieCount = 0;
|
|
6
6
|
vertexCount = 0;
|
|
7
7
|
minBounds = Vector3Like.Create(Infinity, Infinity, Infinity);
|
|
8
8
|
maxBounds = Vector3Like.Create(-Infinity, -Infinity, -Infinity);
|
|
9
|
-
buffer = new VoxelVertexBuffer(VoxelMeshVertexStructCursor.VertexFloatSize,
|
|
10
|
-
indices = new VoxelIndiceBuffer(
|
|
9
|
+
buffer = new VoxelVertexBuffer(VoxelMeshVertexStructCursor.VertexFloatSize, 1024);
|
|
10
|
+
indices = new VoxelIndiceBuffer(1024);
|
|
11
11
|
addVerticies(vertexCount, indicesCount) {
|
|
12
12
|
this.vertexCount += vertexCount;
|
|
13
13
|
this.indicieCount += indicesCount;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Vec3Array } from "@amodx/math";
|
|
2
|
+
import { VoxelMeshBVHStructCursor } from "./VoxelMeshBVHStructCursor";
|
|
3
|
+
import { FlatBinaryTreeIndex } from "../../Util/Binary/BinaryTree";
|
|
4
|
+
export declare class VoxelMeshBVHBuilder {
|
|
5
|
+
static AABBStructByteSize: number;
|
|
6
|
+
treeIndex: FlatBinaryTreeIndex;
|
|
7
|
+
tree: Float32Array;
|
|
8
|
+
structCursor: VoxelMeshBVHStructCursor;
|
|
9
|
+
indices: Uint32Array;
|
|
10
|
+
reset(): void;
|
|
11
|
+
getMeshBounds(): {
|
|
12
|
+
min: Vec3Array;
|
|
13
|
+
max: Vec3Array;
|
|
14
|
+
};
|
|
15
|
+
updateVoxel(voxelX: number, voxelY: number, voxelZ: number, meshIndex: number, indicesStart: number, indicesEnd: number, minX: number, minY: number, minZ: number, maxX: number, maxY: number, maxZ: number): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { WorldSpaces } from "../../World/WorldSpaces";
|
|
2
|
+
import { VoxelMeshBVHStructCursor } from "./VoxelMeshBVHStructCursor";
|
|
3
|
+
import { FlatBinaryTreeIndex } from "../../Util/Binary/BinaryTree";
|
|
4
|
+
const MAX_FLOAT32 = new Float32Array([Infinity])[0];
|
|
5
|
+
export class VoxelMeshBVHBuilder {
|
|
6
|
+
static AABBStructByteSize = (4 + 4) * 4;
|
|
7
|
+
treeIndex = new FlatBinaryTreeIndex(13);
|
|
8
|
+
tree = new Float32Array(new ArrayBuffer(this.treeIndex.getTotalSize() * VoxelMeshBVHBuilder.AABBStructByteSize));
|
|
9
|
+
structCursor = new VoxelMeshBVHStructCursor(this.tree);
|
|
10
|
+
indices = new Uint32Array(this.treeIndex.getLevelSize(12) * 2);
|
|
11
|
+
reset() {
|
|
12
|
+
this.tree.fill(-MAX_FLOAT32);
|
|
13
|
+
this.indices.fill(0);
|
|
14
|
+
}
|
|
15
|
+
getMeshBounds() {
|
|
16
|
+
const leafIndex = this.treeIndex.getIndexAtLevel(0, 0);
|
|
17
|
+
return {
|
|
18
|
+
min: [
|
|
19
|
+
this.tree[leafIndex],
|
|
20
|
+
this.tree[leafIndex + 1],
|
|
21
|
+
this.tree[leafIndex + 2],
|
|
22
|
+
],
|
|
23
|
+
max: [
|
|
24
|
+
this.tree[leafIndex + 4],
|
|
25
|
+
this.tree[leafIndex + 5],
|
|
26
|
+
this.tree[leafIndex + 6],
|
|
27
|
+
],
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
updateVoxel(voxelX, voxelY, voxelZ, meshIndex, indicesStart, indicesEnd, minX, minY, minZ, maxX, maxY, maxZ) {
|
|
31
|
+
const voxelIndex = WorldSpaces.voxel.getIndex(voxelX, voxelY, voxelZ);
|
|
32
|
+
const leafIndex = this.treeIndex.getIndexAtLevel(12, voxelIndex);
|
|
33
|
+
this.indices[voxelIndex * 2] = indicesStart;
|
|
34
|
+
this.indices[voxelIndex * 2 + 1] = indicesEnd;
|
|
35
|
+
this.structCursor.setIndex(leafIndex);
|
|
36
|
+
this.structCursor.updateMin(minX, minY, minZ);
|
|
37
|
+
this.structCursor.updateMax(maxX, maxY, maxZ);
|
|
38
|
+
this.structCursor.setVoxelIndex(voxelIndex);
|
|
39
|
+
this.structCursor.setGeomtryNode();
|
|
40
|
+
let current = leafIndex;
|
|
41
|
+
for (let level = 1; level < 13; level++) {
|
|
42
|
+
let parentNode = this.treeIndex.getParent(current);
|
|
43
|
+
this.structCursor.setIndex(parentNode);
|
|
44
|
+
this.structCursor.updateMin(minX, minY, minZ);
|
|
45
|
+
this.structCursor.updateMax(maxX, maxY, maxZ);
|
|
46
|
+
this.structCursor.setActive();
|
|
47
|
+
this.structCursor.setInnerNode();
|
|
48
|
+
current = parentNode;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare class VoxelMeshBVHStructCursor {
|
|
2
|
+
data: Float32Array;
|
|
3
|
+
get minX(): number;
|
|
4
|
+
get minY(): number;
|
|
5
|
+
get minZ(): number;
|
|
6
|
+
get maxX(): number;
|
|
7
|
+
get maxY(): number;
|
|
8
|
+
get maxZ(): number;
|
|
9
|
+
get voxelIndex(): number;
|
|
10
|
+
get active(): number;
|
|
11
|
+
get nodeType(): number;
|
|
12
|
+
trueIndex: number;
|
|
13
|
+
private index;
|
|
14
|
+
setIndex(index: number): void;
|
|
15
|
+
constructor(data: Float32Array);
|
|
16
|
+
setActive(): void;
|
|
17
|
+
setVoxelIndex(value: number): void;
|
|
18
|
+
setInnerNode(): void;
|
|
19
|
+
setGeomtryNode(): void;
|
|
20
|
+
updateMin(x: number, y: number, z: number): void;
|
|
21
|
+
updateMax(x: number, y: number, z: number): void;
|
|
22
|
+
}
|