@divinevoxel/vlox 0.0.76 → 0.0.78
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 +16 -9
- package/Builder/Tools/Brush/BrushTool.js +258 -52
- package/Builder/Tools/BuilderToolBase.d.ts +36 -0
- package/Builder/Tools/BuilderToolBase.js +39 -0
- package/Builder/Tools/Hand/HandTool.d.ts +9 -7
- package/Builder/Tools/Hand/HandTool.js +40 -23
- package/Builder/Tools/Path/PahtTool.d.ts +12 -7
- package/Builder/Tools/Path/PahtTool.js +32 -21
- package/Builder/Tools/Sculpt/SculptTool.d.ts +34 -0
- package/Builder/Tools/Sculpt/SculptTool.js +102 -0
- package/Builder/Tools/Shape/ShapeTool.d.ts +32 -0
- package/Builder/Tools/Shape/ShapeTool.js +78 -0
- package/Builder/Tools/Template/TemplateTool.d.ts +35 -0
- package/Builder/Tools/Template/TemplateTool.js +73 -0
- package/Builder/Tools/Wand/WandTool.d.ts +9 -7
- package/Builder/Tools/Wand/WandTool.js +43 -20
- package/Builder/Tools/Wrench/WrenchTool.d.ts +7 -7
- package/Builder/Tools/Wrench/WrenchTool.js +22 -13
- package/Builder/Util/FreeBoxSelection.d.ts +12 -0
- package/Builder/Util/FreeBoxSelection.js +21 -0
- package/Builder/Util/FreePointSelection.d.ts +14 -0
- package/Builder/Util/FreePointSelection.js +39 -0
- package/Builder/Util/SurfaceBoxSelection.d.ts +12 -0
- package/Builder/{Tools/Box/BoxSelection.js → Util/SurfaceBoxSelection.js} +1 -3
- package/Builder/VoxelBuildSpace.d.ts +37 -25
- package/Builder/VoxelBuildSpace.js +99 -40
- package/Builder/World/InitTasks.js +17 -22
- package/Mesher/Geomtry/Proto/ProtoMesh.d.ts +18 -0
- package/Mesher/Geomtry/Proto/ProtoMesh.js +73 -0
- package/Mesher/Geomtry/{VoxelMeshBuffers.d.ts → Proto/ProtoMeshBuffer.d.ts} +2 -2
- package/Mesher/Geomtry/{VoxelMeshBuffers.js → Proto/ProtoMeshBuffer.js} +2 -2
- package/Mesher/Geomtry/Shapes/Box.d.ts +2 -9
- package/Mesher/Geomtry/Shapes/Box.js +7 -12
- package/Mesher/Geomtry/Transform/TransformBox.js +5 -2
- package/Mesher/InitMesher.js +4 -4
- package/Mesher/InitTask.js +2 -2
- package/Mesher/Items/Base/CompactItemMesh.d.ts +3 -0
- package/Mesher/Items/Base/CompactItemMesh.js +20 -0
- package/Mesher/Items/Geomtry/ItemGeometryBuilder.d.ts +5 -0
- package/Mesher/Items/Geomtry/ItemGeometryBuilder.js +131 -0
- package/Mesher/Items/Geomtry/ItemMeshVertexStructCursor.d.ts +48 -0
- package/Mesher/Items/Geomtry/ItemMeshVertexStructCursor.js +114 -0
- package/Mesher/Items/MeshTexture.d.ts +1 -0
- package/Mesher/Items/MeshTexture.js +214 -0
- package/Mesher/Items/MeshTextureO.js +277 -0
- package/Mesher/Items/Models/ItemModelBuilder.d.ts +27 -0
- package/Mesher/Items/Models/ItemModelBuilder.js +64 -0
- package/Mesher/Types/ItemMesh.types.d.ts +5 -0
- package/Mesher/Types/ItemMesh.types.js +12 -0
- package/Mesher/Types/Mesher.types.d.ts +15 -9
- package/Mesher/Types/Mesher.types.js +14 -0
- package/Mesher/Types/VoxelMesh.types.js +7 -6
- package/Mesher/Voxels/Base/CompactTemplateMesh.d.ts +3 -0
- package/Mesher/{Functions/CompactVoxelMesh.js → Voxels/Base/CompactTemplateMesh.js} +4 -40
- package/Mesher/{Functions → Voxels/Base}/CompactVoxelSectionMesh.d.ts +2 -2
- package/Mesher/{Functions → Voxels}/Base/MeshSectionBase.d.ts +1 -1
- package/Mesher/{Functions → Voxels}/Base/MeshSectionBase.js +9 -8
- package/Mesher/{Geomtry → Voxels/Geomtry}/CompactedSectionVoxelMesh.d.ts +1 -1
- package/Mesher/{Geomtry → Voxels/Geomtry}/CompactedSectionVoxelMesh.js +1 -1
- package/Mesher/{Geomtry → Voxels/Geomtry}/VoxelGeometryBuilder.d.ts +2 -2
- package/Mesher/{Geomtry → Voxels/Geomtry}/VoxelGeometryBuilder.js +1 -1
- package/Mesher/{Geomtry → Voxels/Geomtry}/VoxelMeshBVHBuilder.d.ts +1 -1
- package/Mesher/{Geomtry → Voxels/Geomtry}/VoxelMeshBVHBuilder.js +2 -2
- package/Mesher/Voxels/MeshTemplate.d.ts +3 -0
- package/Mesher/Voxels/MeshTemplate.js +81 -0
- package/Mesher/{Functions → Voxels}/MeshVoxel.d.ts +1 -1
- package/Mesher/{Functions → Voxels}/MeshVoxel.js +4 -4
- package/Mesher/{Models → Voxels/Models}/Common/Calc/CalcConstants.d.ts +2 -2
- package/Mesher/{Models → Voxels/Models}/Common/Calc/CalcConstants.js +4 -4
- package/Mesher/{Models → Voxels/Models}/Common/Calc/FaceDataCalc.d.ts +1 -1
- package/Mesher/{Models → Voxels/Models}/Common/Calc/FaceDataCalc.js +2 -2
- package/Mesher/{Models → Voxels/Models}/Common/Faces/CullRulledFace.js +1 -1
- package/Mesher/{Models → Voxels/Models}/Common/Faces/ShadeRulelessFace.d.ts +1 -1
- package/Mesher/{Models → Voxels/Models}/Common/Faces/ShadeRulledFace.d.ts +1 -1
- package/Mesher/{Models → Voxels/Models}/Common/Faces/ShadeRulledFace.js +1 -1
- package/Mesher/{Models → Voxels/Models}/Common/GetTexture.d.ts +3 -3
- package/Mesher/{Models → Voxels/Models}/Nodes/Custom/Liquid/FlowGradient.d.ts +1 -1
- package/Mesher/{Models → Voxels/Models}/Nodes/Custom/Liquid/FlowGradient.js +1 -1
- package/Mesher/{Models → Voxels/Models}/Nodes/Custom/Liquid/LiquidGeomtryNode.d.ts +3 -3
- package/Mesher/{Models → Voxels/Models}/Nodes/Custom/Liquid/LiquidGeomtryNode.js +14 -16
- package/Mesher/{Models → Voxels/Models}/Nodes/Default/QuadVoxelGeometryNode.d.ts +2 -2
- package/Mesher/{Models → Voxels/Models}/Nodes/Default/QuadVoxelGeometryNode.js +1 -1
- package/Mesher/{Models → Voxels/Models}/Nodes/Default/TriangleVoxelGeometryNode.d.ts +2 -2
- package/Mesher/{Models → Voxels/Models}/Nodes/Default/TriangleVoxelGeometryNode.js +1 -1
- package/Mesher/{Models → Voxels/Models}/Nodes/Types/QuadVoxelGometryNodeTypes.d.ts +2 -2
- package/Mesher/{Models → Voxels/Models}/Nodes/Types/TriangleVoxelGometryNodeTypes.d.ts +1 -1
- package/Mesher/{Models → Voxels/Models}/Nodes/VoxelGeometryConstructor.d.ts +2 -2
- package/Mesher/Voxels/Models/Procedures/Default/ConsistentRotationTextureProcedure.d.ts +24 -0
- package/Mesher/{Models → Voxels/Models}/Procedures/Default/ConsistentRotationTextureProcedure.js +2 -2
- package/Mesher/{Models → Voxels/Models}/Procedures/Default/OutlinedTextureProcedure.d.ts +4 -5
- package/Mesher/Voxels/Models/Procedures/Default/OutlinedTextureProcedure.js +205 -0
- package/Mesher/Voxels/Models/Procedures/Default/PillarTextureProcedure.d.ts +28 -0
- package/Mesher/Voxels/Models/Procedures/Default/PillarTextureProcedure.js +109 -0
- package/Mesher/{Models → Voxels/Models}/Procedures/TextureProcedure.d.ts +3 -3
- package/Mesher/{Models → Voxels/Models}/Procedures/TextureProcedureRegister.js +2 -0
- package/Mesher/{Models → Voxels/Models}/VoxelConstructor.d.ts +4 -4
- package/Mesher/{Models → Voxels/Models}/VoxelConstructor.js +3 -3
- package/Mesher/{Models → Voxels/Models}/VoxelGeometryBuilderCacheSpace.d.ts +2 -2
- package/Mesher/{Models → Voxels/Models}/VoxelGeometryBuilderCacheSpace.js +2 -2
- package/Mesher/{Models → Voxels/Models}/VoxelModelBuilder.d.ts +7 -7
- package/Mesher/{Models → Voxels/Models}/VoxelModelBuilder.js +6 -5
- package/Mesher/{Models → Voxels/Models}/VoxelModelConstructorRegister.d.ts +4 -4
- package/Mesher/{Models → Voxels/Models}/VoxelModelConstructorRegister.js +2 -2
- package/Mesher/{Models → Voxels/Models}/VoxelModelEffect.d.ts +1 -1
- package/Mesher/{Models → Voxels/Models}/VoxelModelEffect.js +1 -1
- package/Renderer/Classes/DVESectionMeshes.d.ts +1 -1
- package/Renderer/MeshManager.js +1 -1
- package/Settings/EngineSettings.types.d.ts +2 -1
- package/Settings/EngineSettings.types.js +3 -1
- package/Tasks/Paint/Common.js +14 -9
- package/Tasks/Paint/Erase/EraseVoxelSelection.d.ts +4 -0
- package/Tasks/Paint/Erase/EraseVoxelSelection.js +33 -0
- package/Tasks/Paint/Erase/EraseVoxelTemplate.js +1 -2
- package/Tasks/Paint/Paint/PaintVoxel.js +1 -1
- package/Tasks/Paint/Paint/PaintVoxelTemplate.js +1 -1
- package/Tasks/Propagation/Illumanation/RGBUpdate.js +1 -1
- package/Tasks/Tasks.types.d.ts +2 -0
- package/Tasks/TasksIds.d.ts +1 -0
- package/Tasks/TasksIds.js +1 -0
- package/Tasks/WorldGeneration/InitTasks.js +3 -1
- package/Templates/Archive/ArchivedVoxelTemplate.d.ts +5 -5
- package/Templates/Archive/ArchivedVoxelTemplate.js +52 -49
- package/Templates/Archive/Functions/CreateArchivedTemplate.js +0 -2
- package/Templates/Archive/Functions/ExportArchiedTemplateJSON.js +0 -1
- package/Templates/Archive/Functions/ImportArchivedTemplateJSON.js +0 -2
- package/Templates/Cursor/TemplateCursor.d.ts +6 -1
- package/Templates/Cursor/TemplateCursor.js +13 -2
- package/Templates/Cursor/TemplateProxy.js +1 -6
- package/Templates/Cursor/TemplateVoxelCursor.d.ts +1 -0
- package/Templates/Cursor/TemplateVoxelCursor.js +6 -0
- package/Templates/Full/FullVoxelTemplate.d.ts +4 -4
- package/Templates/Full/FullVoxelTemplate.js +29 -18
- package/Templates/Functions/ExtrudeSelection.d.ts +5 -0
- package/Templates/Functions/ExtrudeSelection.js +44 -0
- package/Templates/Functions/FillSelection.d.ts +4 -0
- package/Templates/Functions/FillSelection.js +20 -0
- package/Templates/Functions/FlipTemplate.d.ts +2 -2
- package/Templates/Functions/FlipTemplate.js +8 -8
- package/Templates/Functions/RotateTemplate.d.ts +2 -2
- package/Templates/Path/VoxelPath.js +2 -1
- package/Templates/Selection/VoxelBFSSelection.d.ts +3 -6
- package/Templates/Selection/VoxelBFSSelection.js +20 -24
- package/Templates/Selection/{VoxelBoxSelection.d.ts → VoxelBoundsSelection.d.ts} +9 -6
- package/Templates/Selection/{VoxelBoxSelection.js → VoxelBoundsSelection.js} +29 -22
- package/Templates/Selection/VoxelPointSelection.d.ts +8 -6
- package/Templates/Selection/VoxelPointSelection.js +25 -24
- package/Templates/Selection/VoxelSelection.d.ts +18 -0
- package/Templates/Selection/VoxelSurfaceSelection.d.ts +5 -12
- package/Templates/Selection/VoxelSurfaceSelection.js +76 -90
- package/Templates/Selection/VoxelTemplateSelection.d.ts +10 -4
- package/Templates/Selection/VoxelTemplateSelection.js +18 -10
- package/Templates/Shapes/Selections/BoxVoxelShapeSelection.d.ts +28 -0
- package/Templates/Shapes/Selections/BoxVoxelShapeSelection.js +77 -0
- package/Templates/Shapes/Selections/ConeVoxelShapeSelection.d.ts +28 -0
- package/Templates/Shapes/Selections/ConeVoxelShapeSelection.js +77 -0
- package/Templates/Shapes/Selections/CylinderVoxelShapeSelection.d.ts +28 -0
- package/Templates/Shapes/Selections/CylinderVoxelShapeSelection.js +77 -0
- package/Templates/Shapes/Selections/EllipsoidVoxelShapeSelection.d.ts +28 -0
- package/Templates/Shapes/Selections/EllipsoidVoxelShapeSelection.js +92 -0
- package/Templates/Shapes/Selections/OctahedronVoxelShapeSelection.d.ts +28 -0
- package/Templates/Shapes/Selections/OctahedronVoxelShapeSelection.js +76 -0
- package/Templates/Shapes/Selections/PyramidVoxelShapeSelection.d.ts +37 -0
- package/Templates/Shapes/Selections/PyramidVoxelShapeSelection.js +137 -0
- package/Templates/Shapes/Selections/SphereVoxelShapeSelection.d.ts +20 -0
- package/Templates/Shapes/Selections/SphereVoxelShapeSelection.js +61 -0
- package/Templates/Shapes/Selections/TorusVoxelShapeSelection.d.ts +28 -0
- package/Templates/Shapes/Selections/TorusVoxelShapeSelection.js +76 -0
- package/Templates/Shapes/Selections/VoxelShapeSelection.d.ts +5 -0
- package/Templates/Shapes/Selections/VoxelShapeSelection.js +1 -0
- package/Templates/Shapes/VoxelShape.types.d.ts +2 -0
- package/Templates/Shapes/VoxelShape.types.js +8 -0
- package/Templates/Shapes/VoxelShapeTemplate.d.ts +37 -0
- package/Templates/Shapes/{BasicVoxelShapeTemplate.js → VoxelShapeTemplate.js} +43 -37
- package/Templates/Shapes/VoxelShapeTemplate.types.d.ts +4 -13
- package/Templates/Shapes/VoxelShapeTemplate.types.js +0 -1
- package/Templates/{VoxelTempateRegister.d.ts → VoxelTemplateRegister.d.ts} +4 -0
- package/Templates/VoxelTemplateRegister.js +60 -0
- package/Templates/VoxelTemplates.types.d.ts +2 -3
- package/Textures/Classes/CompiledTexture.d.ts +2 -0
- package/Textures/Classes/CompiledTexture.js +19 -1
- package/Textures/Functions/BuildTextureData.js +13 -0
- package/Textures/TextureManager.d.ts +1 -0
- package/Textures/TextureManager.js +11 -5
- package/Tools/Brush/Brush.d.ts +2 -0
- package/Tools/Brush/Brush.js +19 -0
- package/Tools/Tasks/TasksTool.d.ts +2 -1
- package/Tools/Tasks/TasksTool.js +2 -0
- package/Voxels/Cursor/DataCursor.interface.d.ts +4 -0
- package/Voxels/Cursor/VoxelLightData.js +2 -2
- package/Voxels/Functions/BuildTagData.js +1 -1
- package/Voxels/Indexes/VoxelIndex.d.ts +1 -0
- package/Voxels/Indexes/VoxelIndex.js +11 -13
- package/Voxels/InitVoxelData.js +5 -14
- package/Voxels/Interaction/Functions/PickVoxel.d.ts +0 -5
- package/Voxels/Interaction/Functions/PickVoxel.js +64 -85
- package/Voxels/Interaction/Functions/PickVoxelWorld.js +6 -3
- package/Voxels/Models/CompiledVoxelModel.types.d.ts +1 -1
- package/Voxels/Models/Defaults/CubeVoxelGeometry.js +11 -0
- package/Voxels/Models/Defaults/CubeVoxelModels.js +44 -99
- package/Voxels/Models/Defaults/PanelVoxelGeometry.d.ts +1 -3
- package/Voxels/Models/Defaults/PanelVoxelGeometry.js +2 -226
- package/Voxels/Models/Defaults/PanelVoxelModels.d.ts +1 -0
- package/Voxels/Models/Defaults/PanelVoxelModels.js +100 -258
- package/Voxels/Models/Defaults/StairVoxelModel.js +2 -2
- package/Voxels/Models/Rules/Classes/GeomtryInput.d.ts +4 -1
- package/Voxels/Models/Rules/Classes/GeomtryInput.js +26 -5
- package/Voxels/Models/Rules/Classes/VoxelRulesGeometry.d.ts +1 -1
- package/Voxels/Models/Rules/Functions/BuildFinalInputs.js +23 -8
- package/Voxels/Models/Rules/Functions/Compile/CompileGeomtryNodes.d.ts +1 -1
- package/Voxels/Models/Rules/Functions/Compile/Nodes/CompileBoxGeometryNode.d.ts +1 -1
- package/Voxels/Models/Rules/Functions/Compile/Nodes/CompileQuadGeometryNode.d.ts +1 -1
- package/Voxels/Models/Rules/Functions/Compile/Nodes/CompileQuadGeometryNode.js +1 -1
- package/Voxels/Models/Rules/Functions/Compile/Nodes/CompileTriangleGeometryNode.d.ts +1 -1
- package/Voxels/Models/Rules/Functions/Compile/Nodes/CompileTriangleGeometryNode.js +1 -1
- package/Voxels/Models/VoxelModel.types.d.ts +6 -1
- package/Voxels/Types/PaintVoxelData.d.ts +2 -0
- package/Voxels/Types/PaintVoxelData.js +51 -0
- package/World/Cursor/SectionCursor.d.ts +4 -0
- package/World/Cursor/SectionCursor.js +13 -16
- package/World/Cursor/SectorCursor.d.ts +4 -0
- package/World/Cursor/SectorCursor.js +13 -16
- package/World/Cursor/WorldCursor.d.ts +4 -0
- package/World/Cursor/WorldCursor.js +8 -0
- package/World/Sector/SectorHeightMap.d.ts +6 -0
- package/World/Sector/SectorHeightMap.js +6 -0
- package/World/SnapShot/SectionSnapShotCursor.d.ts +3 -0
- package/World/SnapShot/SectionSnapShotCursor.js +6 -0
- package/World/WorldSpaces.js +3 -3
- package/WorldSimulation/Dimensions/DimensionSimulation.d.ts +5 -1
- package/WorldSimulation/Dimensions/DimensionSimulation.js +12 -0
- package/WorldSimulation/Dimensions/Generator.d.ts +1 -0
- package/WorldSimulation/Dimensions/Generator.js +1 -0
- package/WorldSimulation/Dimensions/SimulationSector.d.ts +3 -0
- package/WorldSimulation/Dimensions/SimulationSector.js +71 -41
- package/WorldSimulation/Internal/WorldSimulationTasks.js +5 -2
- package/WorldSimulation/Procedures/BuildOnly.d.ts +10 -0
- package/WorldSimulation/Procedures/BuildOnly.js +55 -0
- package/WorldSimulation/Procedures/InitalLoad.js +3 -0
- package/WorldSimulation/Tasks/SimulationTaskBase.d.ts +2 -0
- package/WorldSimulation/Tasks/SimulationTaskBase.js +11 -3
- package/WorldSimulation/Tasks/TaskSegment.d.ts +2 -1
- package/WorldSimulation/Tasks/TaskSegment.js +3 -1
- package/WorldSimulation/Tick/TickQueue.d.ts +2 -0
- package/WorldSimulation/Tick/TickQueue.js +26 -0
- package/WorldSimulation/Tools/SimulationBrush.d.ts +3 -0
- package/WorldSimulation/Tools/SimulationBrush.js +52 -0
- package/WorldSimulation/Voxels/Behaviors/Types/DefaultVoxelBehavior.js +3 -0
- package/WorldSimulation/Voxels/Behaviors/Types/LiquidVoxelBehavior.js +21 -1
- package/WorldSimulation/Voxels/Behaviors/VoxelBehaviors.d.ts +2 -0
- package/WorldSimulation/Voxels/Behaviors/VoxelBehaviors.js +6 -0
- package/WorldSimulation/Voxels/Ticks/Types/LiquidVoxelUpdate.js +39 -14
- package/WorldSimulation/WorldSimulation.d.ts +10 -0
- package/WorldSimulation/WorldSimulation.js +41 -1
- package/package.json +1 -30
- package/Builder/Tools/Box/BoxSelection.d.ts +0 -12
- package/Builder/Tools/Box/BoxTool.d.ts +0 -31
- package/Builder/Tools/Box/BoxTool.js +0 -91
- package/Builder/Tools/Box/BoxToolTemplate.d.ts +0 -13
- package/Builder/Tools/Box/BoxToolTemplate.js +0 -23
- package/Builder/VoxelBuilder.types.d.ts +0 -0
- package/Builder/VoxelBuilder.types.js +0 -1
- package/Mesher/Functions/CompactVoxelMesh.d.ts +0 -3
- package/Mesher/Functions/MeshTexture.js +0 -278
- package/Mesher/Geomtry/VoxelMesh.d.ts +0 -12
- package/Mesher/Geomtry/VoxelMesh.js +0 -25
- package/Mesher/Models/Procedures/Default/ConsistentRotationTextureProcedure.d.ts +0 -25
- package/Mesher/Models/Procedures/Default/OutlinedTextureProcedure.js +0 -162
- package/Templates/Selection/VoxelSelecton.d.ts +0 -9
- package/Templates/Shapes/BasicVoxelShapeTemplate.d.ts +0 -36
- package/Templates/Shapes/BoxVoxelTemplate.d.ts +0 -23
- package/Templates/Shapes/BoxVoxelTemplate.js +0 -83
- package/Templates/Shapes/ConeVoxelTemplate.d.ts +0 -23
- package/Templates/Shapes/ConeVoxelTemplate.js +0 -73
- package/Templates/Shapes/CylinderVoxelTemplate.d.ts +0 -23
- package/Templates/Shapes/CylinderVoxelTemplate.js +0 -73
- package/Templates/Shapes/EllipsoidVoxelTemplate.d.ts +0 -23
- package/Templates/Shapes/EllipsoidVoxelTemplate.js +0 -89
- package/Templates/Shapes/OctahedronVoxelTemplate.d.ts +0 -23
- package/Templates/Shapes/OctahedronVoxelTemplate.js +0 -73
- package/Templates/Shapes/PyramidVoxelTemplate.d.ts +0 -31
- package/Templates/Shapes/PyramidVoxelTemplate.js +0 -148
- package/Templates/Shapes/SphereVoxelTemplate.d.ts +0 -15
- package/Templates/Shapes/SphereVoxelTemplate.js +0 -59
- package/Templates/Shapes/TorusVoxelTemplate.d.ts +0 -23
- package/Templates/Shapes/TorusVoxelTemplate.js +0 -73
- package/Templates/VoxelTempateRegister.js +0 -30
- /package/Mesher/{Functions/MeshTexture.d.ts → Items/MeshTextureO.d.ts} +0 -0
- /package/Mesher/{Functions → Voxels/Base}/CompactVoxelSectionMesh.js +0 -0
- /package/Mesher/{Geomtry → Voxels/Geomtry}/VoxelMeshBVHStructCursor.d.ts +0 -0
- /package/Mesher/{Geomtry → Voxels/Geomtry}/VoxelMeshBVHStructCursor.js +0 -0
- /package/Mesher/{Geomtry → Voxels/Geomtry}/VoxelMeshVertexStructCursor.d.ts +0 -0
- /package/Mesher/{Geomtry → Voxels/Geomtry}/VoxelMeshVertexStructCursor.js +0 -0
- /package/Mesher/{Geomtry → Voxels/Geomtry}/VoxelShaderData.d.ts +0 -0
- /package/Mesher/{Geomtry → Voxels/Geomtry}/VoxelShaderData.js +0 -0
- /package/Mesher/{Functions → Voxels}/MeshSection.d.ts +0 -0
- /package/Mesher/{Functions → Voxels}/MeshSection.js +0 -0
- /package/Mesher/{Functions → Voxels}/MeshSectionSnapShot.d.ts +0 -0
- /package/Mesher/{Functions → Voxels}/MeshSectionSnapShot.js +0 -0
- /package/Mesher/{Models → Voxels/Models}/Common/Faces/CullRulledFace.d.ts +0 -0
- /package/Mesher/{Models → Voxels/Models}/Common/Faces/ShadeRulelessFace.js +0 -0
- /package/Mesher/{Models → Voxels/Models}/Common/GetTexture.js +0 -0
- /package/Mesher/{Models → Voxels/Models}/Nodes/Custom/index.d.ts +0 -0
- /package/Mesher/{Models → Voxels/Models}/Nodes/Custom/index.js +0 -0
- /package/Mesher/{Models → Voxels/Models}/Nodes/GeometryNode.d.ts +0 -0
- /package/Mesher/{Models → Voxels/Models}/Nodes/GeometryNode.js +0 -0
- /package/Mesher/{Models → Voxels/Models}/Nodes/Types/GeomtryNode.types.d.ts +0 -0
- /package/Mesher/{Models → Voxels/Models}/Nodes/Types/GeomtryNode.types.js +0 -0
- /package/Mesher/{Models → Voxels/Models}/Nodes/Types/QuadVoxelGometryNodeTypes.js +0 -0
- /package/Mesher/{Models → Voxels/Models}/Nodes/Types/TriangleVoxelGometryNodeTypes.js +0 -0
- /package/Mesher/{Models → Voxels/Models}/Nodes/VoxelGeometryConstructor.js +0 -0
- /package/Mesher/{Models → Voxels/Models}/Procedures/TextureProcedure.js +0 -0
- /package/Mesher/{Models → Voxels/Models}/Procedures/TextureProcedureRegister.d.ts +0 -0
- /package/Mesher/{Models → Voxels/Models}/RenderedMaterials.d.ts +0 -0
- /package/Mesher/{Models → Voxels/Models}/RenderedMaterials.js +0 -0
- /package/Templates/Selection/{VoxelSelecton.js → VoxelSelection.js} +0 -0
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { QuadVerticies } from "../Geomtry/Geometry.types";
|
|
2
|
+
import { Quad } from "../Geomtry/Primitives/Quad";
|
|
3
|
+
import { ItemModelBuilder } from "./Models/ItemModelBuilder";
|
|
4
|
+
import { addItemQuad } from "./Geomtry/ItemGeometryBuilder";
|
|
5
|
+
import { Flat2DIndex } from "@amodx/math";
|
|
6
|
+
import { Box } from "../Geomtry/Shapes/Box";
|
|
7
|
+
import { VoxelFaces } from "../../Math";
|
|
8
|
+
import { CompactItemMesh } from "./Base/CompactItemMesh";
|
|
9
|
+
const { quads: Quads } = Box.Create([
|
|
10
|
+
[0, 0, 0],
|
|
11
|
+
[1, 1, 1],
|
|
12
|
+
]);
|
|
13
|
+
const addUvs = (quad, factor, sx, sy, ex, ey) => {
|
|
14
|
+
const uR = ex * factor;
|
|
15
|
+
const uL = sx * factor;
|
|
16
|
+
const vT = ey * factor;
|
|
17
|
+
const vB = sy * factor;
|
|
18
|
+
quad.uvs.vertices[QuadVerticies.TopRight].x = uR;
|
|
19
|
+
quad.uvs.vertices[QuadVerticies.TopRight].y = vT;
|
|
20
|
+
quad.uvs.vertices[QuadVerticies.TopLeft].x = uL;
|
|
21
|
+
quad.uvs.vertices[QuadVerticies.TopLeft].y = vT;
|
|
22
|
+
quad.uvs.vertices[QuadVerticies.BottomLeft].x = uL;
|
|
23
|
+
quad.uvs.vertices[QuadVerticies.BottomLeft].y = vB;
|
|
24
|
+
quad.uvs.vertices[QuadVerticies.BottomRight].x = uR;
|
|
25
|
+
quad.uvs.vertices[QuadVerticies.BottomRight].y = vB;
|
|
26
|
+
};
|
|
27
|
+
class TextureVoxelData {
|
|
28
|
+
width;
|
|
29
|
+
height;
|
|
30
|
+
textureData;
|
|
31
|
+
index = Flat2DIndex.GetXYOrder();
|
|
32
|
+
constructor(width, height, textureData) {
|
|
33
|
+
this.width = width;
|
|
34
|
+
this.height = height;
|
|
35
|
+
this.textureData = textureData;
|
|
36
|
+
this.index.setBounds(width, height);
|
|
37
|
+
}
|
|
38
|
+
inBounds(x, y) {
|
|
39
|
+
return x >= 0 && x < this.width && y >= 0 && y < this.height;
|
|
40
|
+
}
|
|
41
|
+
isSolid(x, y) {
|
|
42
|
+
if (!this.inBounds(x, y))
|
|
43
|
+
return false;
|
|
44
|
+
const a = this.textureData[this.index.getIndexXY(x, this.height - 1 - y) * 4 + 3];
|
|
45
|
+
return a > 0.01;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
Quads[VoxelFaces.North].setUVs(Quad.FullUVs);
|
|
49
|
+
Quads[VoxelFaces.South].setUVs(Quad.FullUVs);
|
|
50
|
+
const tool = new ItemModelBuilder("dve_item");
|
|
51
|
+
export function MeshTexture(textureId, textureData) {
|
|
52
|
+
const width = Math.sqrt(textureData.length / 4);
|
|
53
|
+
const height = Math.sqrt(textureData.length / 4);
|
|
54
|
+
const factor = 1 / width;
|
|
55
|
+
const data = new TextureVoxelData(width, height, textureData);
|
|
56
|
+
{
|
|
57
|
+
//south face
|
|
58
|
+
tool.vars.textureIndex = textureId;
|
|
59
|
+
addItemQuad(tool, Quads[VoxelFaces.South]);
|
|
60
|
+
}
|
|
61
|
+
{
|
|
62
|
+
//north face
|
|
63
|
+
const backPositionZ = factor;
|
|
64
|
+
Quads[VoxelFaces.North].positions.vertices[QuadVerticies.TopRight].z =
|
|
65
|
+
backPositionZ;
|
|
66
|
+
Quads[VoxelFaces.North].positions.vertices[QuadVerticies.TopLeft].z =
|
|
67
|
+
backPositionZ;
|
|
68
|
+
Quads[VoxelFaces.North].positions.vertices[QuadVerticies.BottomLeft].z =
|
|
69
|
+
backPositionZ;
|
|
70
|
+
Quads[VoxelFaces.North].positions.vertices[QuadVerticies.BottomRight].z =
|
|
71
|
+
backPositionZ;
|
|
72
|
+
tool.vars.textureIndex = textureId;
|
|
73
|
+
addItemQuad(tool, Quads[VoxelFaces.North]);
|
|
74
|
+
}
|
|
75
|
+
for (let x = 0; x < width; x++) {
|
|
76
|
+
let eastFace = null;
|
|
77
|
+
let westFace = null;
|
|
78
|
+
for (let y = 0; y < height; y++) {
|
|
79
|
+
let eastFaceExposed = true;
|
|
80
|
+
let westFaceExposed = true;
|
|
81
|
+
if (!data.isSolid(x, y)) {
|
|
82
|
+
eastFaceExposed = false;
|
|
83
|
+
westFaceExposed = false;
|
|
84
|
+
}
|
|
85
|
+
if (data.isSolid(x + 1, y)) {
|
|
86
|
+
eastFaceExposed = false;
|
|
87
|
+
}
|
|
88
|
+
if (data.isSolid(x - 1, y)) {
|
|
89
|
+
westFaceExposed = false;
|
|
90
|
+
}
|
|
91
|
+
if (eastFace && !eastFaceExposed) {
|
|
92
|
+
const x1 = x * factor + factor;
|
|
93
|
+
const y0 = eastFace[1] * factor;
|
|
94
|
+
const y1 = y * factor;
|
|
95
|
+
const z0 = 0;
|
|
96
|
+
const z1 = factor;
|
|
97
|
+
// Flip winding vs previous: (p1 <-> p3)
|
|
98
|
+
const newQuad = Quad.Create([
|
|
99
|
+
[x1, y0, z0], // p0
|
|
100
|
+
[x1, y0, z1], // p1 (was p3)
|
|
101
|
+
[x1, y1, z1], // p2
|
|
102
|
+
[x1, y1, z0], // p3 (was p1)
|
|
103
|
+
], Quad.FullUVs, false);
|
|
104
|
+
let [sx, sy] = eastFace;
|
|
105
|
+
let ex = x + 1;
|
|
106
|
+
let ey = y;
|
|
107
|
+
addUvs(newQuad, factor, sx, sy, ex, ey);
|
|
108
|
+
eastFace = null;
|
|
109
|
+
tool.vars.textureIndex = textureId;
|
|
110
|
+
addItemQuad(tool, newQuad);
|
|
111
|
+
}
|
|
112
|
+
if (westFace && !westFaceExposed) {
|
|
113
|
+
const x0 = x * factor;
|
|
114
|
+
const y0 = westFace[1] * factor;
|
|
115
|
+
const y1 = y * factor;
|
|
116
|
+
const z0 = 0;
|
|
117
|
+
const z1 = factor;
|
|
118
|
+
// Flip winding vs previous: (p1 <-> p3)
|
|
119
|
+
const newQuad = Quad.Create([
|
|
120
|
+
[x0, y0, z0], // p0
|
|
121
|
+
[x0, y1, z0], // p1 (was p3)
|
|
122
|
+
[x0, y1, z1], // p2
|
|
123
|
+
[x0, y0, z1], // p3 (was p1)
|
|
124
|
+
], Quad.FullUVs, false);
|
|
125
|
+
let [sx, sy] = westFace;
|
|
126
|
+
let ex = x + 1;
|
|
127
|
+
let ey = y;
|
|
128
|
+
addUvs(newQuad, factor, sx, sy, ex, ey);
|
|
129
|
+
westFace = null;
|
|
130
|
+
tool.vars.textureIndex = textureId;
|
|
131
|
+
addItemQuad(tool, newQuad);
|
|
132
|
+
}
|
|
133
|
+
const isPixel = data.isSolid(x, y);
|
|
134
|
+
if (!data.isSolid(x + 1, y) && !eastFace && isPixel) {
|
|
135
|
+
eastFace = [x, y];
|
|
136
|
+
}
|
|
137
|
+
if (!data.isSolid(x - 1, y) && !westFace && isPixel) {
|
|
138
|
+
westFace = [x, y];
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
for (let y = 0; y < height; y++) {
|
|
143
|
+
let upFace = null;
|
|
144
|
+
let downFace = null;
|
|
145
|
+
for (let x = 0; x < width; x++) {
|
|
146
|
+
let upFaceExposed = true;
|
|
147
|
+
let downFaceExposed = true;
|
|
148
|
+
if (!data.isSolid(x, y)) {
|
|
149
|
+
upFaceExposed = false;
|
|
150
|
+
downFaceExposed = false;
|
|
151
|
+
}
|
|
152
|
+
if (data.isSolid(x, y + 1)) {
|
|
153
|
+
upFaceExposed = false;
|
|
154
|
+
}
|
|
155
|
+
if (data.isSolid(x, y - 1)) {
|
|
156
|
+
downFaceExposed = false;
|
|
157
|
+
}
|
|
158
|
+
if (upFace && !upFaceExposed) {
|
|
159
|
+
const x0 = upFace[0] * factor;
|
|
160
|
+
const x1 = x * factor;
|
|
161
|
+
const y1 = y * factor + factor;
|
|
162
|
+
const z0 = 0;
|
|
163
|
+
const z1 = factor;
|
|
164
|
+
// +Y normal — CCW when viewed from +Y
|
|
165
|
+
const newQuad = Quad.Create([
|
|
166
|
+
[x0, y1, z0], // p0
|
|
167
|
+
[x1, y1, z0], // p1
|
|
168
|
+
[x1, y1, z1], // p2
|
|
169
|
+
[x0, y1, z1], // p3
|
|
170
|
+
], Quad.FullUVs, false
|
|
171
|
+
// 0
|
|
172
|
+
);
|
|
173
|
+
let [sx, sy] = upFace;
|
|
174
|
+
let [ex, ey] = [x, y];
|
|
175
|
+
ey += 1;
|
|
176
|
+
addUvs(newQuad, factor, sx, sy, ex, ey);
|
|
177
|
+
upFace = null;
|
|
178
|
+
tool.vars.textureIndex = textureId;
|
|
179
|
+
addItemQuad(tool, newQuad);
|
|
180
|
+
}
|
|
181
|
+
if (downFace && !downFaceExposed) {
|
|
182
|
+
const x0 = downFace[0] * factor;
|
|
183
|
+
const x1 = x * factor;
|
|
184
|
+
const y0 = y * factor;
|
|
185
|
+
const z0 = 0;
|
|
186
|
+
const z1 = factor;
|
|
187
|
+
// -Y normal — flip winding relative to +Y
|
|
188
|
+
const newQuad = Quad.Create([
|
|
189
|
+
[x0, y0, z0], // p0
|
|
190
|
+
[x0, y0, z1], // p1
|
|
191
|
+
[x1, y0, z1], // p2
|
|
192
|
+
[x1, y0, z0], // p3
|
|
193
|
+
], Quad.FullUVs, false
|
|
194
|
+
// 1
|
|
195
|
+
);
|
|
196
|
+
let [sx, sy] = downFace;
|
|
197
|
+
let [ex, ey] = [x, y];
|
|
198
|
+
ey += 1;
|
|
199
|
+
addUvs(newQuad, factor, sx, sy, ex, ey);
|
|
200
|
+
downFace = null;
|
|
201
|
+
tool.vars.textureIndex = textureId;
|
|
202
|
+
addItemQuad(tool, newQuad);
|
|
203
|
+
}
|
|
204
|
+
const isPixel = data.isSolid(x, y);
|
|
205
|
+
if (!data.isSolid(x, y + 1) && !upFace && isPixel) {
|
|
206
|
+
upFace = [x, y];
|
|
207
|
+
}
|
|
208
|
+
if (!data.isSolid(x, y - 1) && !downFace && isPixel) {
|
|
209
|
+
downFace = [x, y];
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return CompactItemMesh([tool]);
|
|
214
|
+
}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import { Quad } from "../Geomtry/Primitives/Quad";
|
|
2
|
+
const Quads = {
|
|
3
|
+
north: Quad.Create([
|
|
4
|
+
[1, 1, 0],
|
|
5
|
+
[0, 1, 0],
|
|
6
|
+
[0, 0, 0],
|
|
7
|
+
[1, 0, 0],
|
|
8
|
+
], Quad.FullUVs),
|
|
9
|
+
south: Quad.Create([
|
|
10
|
+
[1, 1, 0],
|
|
11
|
+
[0, 1, 0],
|
|
12
|
+
[0, 0, 0],
|
|
13
|
+
[1, 0, 0],
|
|
14
|
+
], Quad.FullUVs),
|
|
15
|
+
};
|
|
16
|
+
//const tool = new MesherDataTool();
|
|
17
|
+
//tool.startNewMesh();
|
|
18
|
+
//tool.mesh!.attributes.set("uv", [[], 2, BinaryNumberTypes.Float32]);
|
|
19
|
+
//tool.mesh!.attributes.set("textureIndex", [[], 3, BinaryNumberTypes.Float32]);
|
|
20
|
+
export function MeshTexture(textureId, textureData) {
|
|
21
|
+
/* const width = Math.sqrt(textureData.length / 4);
|
|
22
|
+
const height = Math.sqrt(textureData.length / 4);
|
|
23
|
+
const factor = 1 / width;
|
|
24
|
+
|
|
25
|
+
const textureDataIndex = Flat2DIndex.GetXYOrder();
|
|
26
|
+
textureDataIndex.setBounds(width, height);
|
|
27
|
+
|
|
28
|
+
const origin = Vector3Like.Create(-0.5, -0.5, -0.5);
|
|
29
|
+
|
|
30
|
+
const isSolid = (x: number, y: number) =>
|
|
31
|
+
x >= 0 &&
|
|
32
|
+
x < width &&
|
|
33
|
+
y >= 0 &&
|
|
34
|
+
y < height &&
|
|
35
|
+
textureData[textureDataIndex.getIndexXY(x, y) * 4 + 3] > 0.01
|
|
36
|
+
? true
|
|
37
|
+
: false;
|
|
38
|
+
|
|
39
|
+
const uvs = tool.mesh!.getAttribute("uv");
|
|
40
|
+
const textureIndex = tool.mesh!.getAttribute("textureIndex");
|
|
41
|
+
const uvOffset = width > 16 ? -(2 / Math.max(width, height)) : 0;
|
|
42
|
+
|
|
43
|
+
const addUvs = (sx: number, sy: number, ex: number, ey: number) => {
|
|
44
|
+
uvs.push(
|
|
45
|
+
(ex + uvOffset) * factor,
|
|
46
|
+
(ey + uvOffset) * factor,
|
|
47
|
+
(sx - uvOffset) * factor,
|
|
48
|
+
(ey + uvOffset) * factor,
|
|
49
|
+
(sx - uvOffset) * factor,
|
|
50
|
+
(sy - uvOffset) * factor,
|
|
51
|
+
(ex + uvOffset) * factor,
|
|
52
|
+
(sy - uvOffset) * factor
|
|
53
|
+
);
|
|
54
|
+
textureIndex.push(
|
|
55
|
+
textureId,
|
|
56
|
+
0,
|
|
57
|
+
0,
|
|
58
|
+
textureId,
|
|
59
|
+
0,
|
|
60
|
+
0,
|
|
61
|
+
textureId,
|
|
62
|
+
0,
|
|
63
|
+
0,
|
|
64
|
+
textureId,
|
|
65
|
+
0,
|
|
66
|
+
0
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
{
|
|
71
|
+
GeometryBuilder.addQuad(tool, origin, Quads.south);
|
|
72
|
+
uvs.push(
|
|
73
|
+
Quads.south.uvs.vertices[QuadVerticies.TopRight].x,
|
|
74
|
+
Quads.south.uvs.vertices[QuadVerticies.TopRight].y,
|
|
75
|
+
Quads.south.uvs.vertices[QuadVerticies.TopLeft].x,
|
|
76
|
+
Quads.south.uvs.vertices[QuadVerticies.TopLeft].y,
|
|
77
|
+
Quads.south.uvs.vertices[QuadVerticies.BottomLeft].x,
|
|
78
|
+
Quads.south.uvs.vertices[QuadVerticies.BottomLeft].y,
|
|
79
|
+
Quads.south.uvs.vertices[QuadVerticies.BottomRight].x,
|
|
80
|
+
Quads.south.uvs.vertices[QuadVerticies.BottomRight].y
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
textureIndex.push(
|
|
84
|
+
textureId,
|
|
85
|
+
0,
|
|
86
|
+
0,
|
|
87
|
+
textureId,
|
|
88
|
+
0,
|
|
89
|
+
0,
|
|
90
|
+
textureId,
|
|
91
|
+
0,
|
|
92
|
+
0,
|
|
93
|
+
textureId,
|
|
94
|
+
0,
|
|
95
|
+
0
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
{
|
|
100
|
+
const backPositionZ = factor;
|
|
101
|
+
Quads.north.positions.vertices[QuadVerticies.TopRight].z = backPositionZ;
|
|
102
|
+
Quads.north.positions.vertices[QuadVerticies.TopLeft].z = backPositionZ;
|
|
103
|
+
Quads.north.positions.vertices[QuadVerticies.BottomLeft].z = backPositionZ;
|
|
104
|
+
Quads.north.positions.vertices[QuadVerticies.BottomRight].z = backPositionZ;
|
|
105
|
+
Quads.north.flip = true;
|
|
106
|
+
uvs.push(
|
|
107
|
+
Quads.north.uvs.vertices[QuadVerticies.TopLeft].x,
|
|
108
|
+
Quads.north.uvs.vertices[QuadVerticies.TopLeft].y,
|
|
109
|
+
Quads.north.uvs.vertices[QuadVerticies.TopRight].x,
|
|
110
|
+
Quads.north.uvs.vertices[QuadVerticies.TopRight].y,
|
|
111
|
+
Quads.north.uvs.vertices[QuadVerticies.BottomRight].x,
|
|
112
|
+
Quads.north.uvs.vertices[QuadVerticies.BottomRight].y,
|
|
113
|
+
Quads.north.uvs.vertices[QuadVerticies.BottomLeft].x,
|
|
114
|
+
Quads.north.uvs.vertices[QuadVerticies.BottomLeft].y
|
|
115
|
+
);
|
|
116
|
+
GeometryBuilder.addQuad(tool, origin, Quads.north);
|
|
117
|
+
textureIndex.push(
|
|
118
|
+
textureId,
|
|
119
|
+
0,
|
|
120
|
+
0,
|
|
121
|
+
textureId,
|
|
122
|
+
0,
|
|
123
|
+
0,
|
|
124
|
+
textureId,
|
|
125
|
+
0,
|
|
126
|
+
0,
|
|
127
|
+
textureId,
|
|
128
|
+
0,
|
|
129
|
+
0
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
for (let x = 0; x < width; x++) {
|
|
134
|
+
let eastFace: Vec2Array | null = null;
|
|
135
|
+
let westFace: Vec2Array | null = null;
|
|
136
|
+
for (let y = 0; y < height; y++) {
|
|
137
|
+
let eastFaceExposed = true;
|
|
138
|
+
let westFaceExposed = true;
|
|
139
|
+
|
|
140
|
+
if (!isSolid(x, y)) {
|
|
141
|
+
eastFaceExposed = false;
|
|
142
|
+
westFaceExposed = false;
|
|
143
|
+
}
|
|
144
|
+
if (isSolid(x + 1, y)) {
|
|
145
|
+
eastFaceExposed = false;
|
|
146
|
+
}
|
|
147
|
+
if (isSolid(x - 1, y)) {
|
|
148
|
+
westFaceExposed = false;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (eastFace && !eastFaceExposed) {
|
|
152
|
+
const newQuad = Quad.Create(
|
|
153
|
+
[
|
|
154
|
+
[x * factor + factor, eastFace[1] * factor, 0],
|
|
155
|
+
[x * factor + factor, y * factor, factor],
|
|
156
|
+
],
|
|
157
|
+
Quad.FullUVs as any,
|
|
158
|
+
false,
|
|
159
|
+
0
|
|
160
|
+
);
|
|
161
|
+
GeometryBuilder.addQuad(tool, origin, newQuad);
|
|
162
|
+
|
|
163
|
+
let [sx, sy] = eastFace;
|
|
164
|
+
let ex = x;
|
|
165
|
+
let ey = y;
|
|
166
|
+
ex += 1;
|
|
167
|
+
addUvs(sx, sy, ex, ey);
|
|
168
|
+
eastFace = null;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (westFace && !westFaceExposed) {
|
|
172
|
+
const newQuad = Quad.Create(
|
|
173
|
+
[
|
|
174
|
+
[x * factor, westFace[1] * factor, 0],
|
|
175
|
+
[x * factor, y * factor, factor],
|
|
176
|
+
],
|
|
177
|
+
Quad.FullUVs as any,
|
|
178
|
+
false,
|
|
179
|
+
1
|
|
180
|
+
);
|
|
181
|
+
GeometryBuilder.addQuad(tool, origin, newQuad);
|
|
182
|
+
let [sx, sy] = westFace;
|
|
183
|
+
let ex = x;
|
|
184
|
+
let ey = y;
|
|
185
|
+
ex += 1;
|
|
186
|
+
addUvs(sx, sy, ex, ey);
|
|
187
|
+
westFace = null;
|
|
188
|
+
}
|
|
189
|
+
const isPixel = isSolid(x, y);
|
|
190
|
+
if (!isSolid(x + 1, y) && !eastFace && isPixel) {
|
|
191
|
+
eastFace = [x, y];
|
|
192
|
+
}
|
|
193
|
+
if (!isSolid(x - 1, y) && !westFace && isPixel) {
|
|
194
|
+
westFace = [x, y];
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
for (let y = 0; y < height; y++) {
|
|
199
|
+
let upFace: Vec2Array | null = null;
|
|
200
|
+
let downFace: Vec2Array | null = null;
|
|
201
|
+
|
|
202
|
+
for (let x = 0; x < width; x++) {
|
|
203
|
+
let upFaceExposed = true;
|
|
204
|
+
let downFaceExposed = true;
|
|
205
|
+
|
|
206
|
+
if (!isSolid(x, y)) {
|
|
207
|
+
upFaceExposed = false;
|
|
208
|
+
downFaceExposed = false;
|
|
209
|
+
}
|
|
210
|
+
if (isSolid(x, y + 1)) {
|
|
211
|
+
upFaceExposed = false;
|
|
212
|
+
}
|
|
213
|
+
if (isSolid(x, y - 1)) {
|
|
214
|
+
downFaceExposed = false;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (upFace && !upFaceExposed) {
|
|
218
|
+
const newQuad = Quad.Create(
|
|
219
|
+
[
|
|
220
|
+
[upFace[0] * factor, y * factor + factor, 0],
|
|
221
|
+
[x * factor, y * factor + factor, factor],
|
|
222
|
+
],
|
|
223
|
+
Quad.FullUVs as any,
|
|
224
|
+
false,
|
|
225
|
+
0
|
|
226
|
+
);
|
|
227
|
+
GeometryBuilder.addQuad(tool, origin, newQuad);
|
|
228
|
+
let [sx, sy] = upFace;
|
|
229
|
+
let [ex, ey] = [x, y];
|
|
230
|
+
|
|
231
|
+
ey += 1;
|
|
232
|
+
addUvs(sx, sy, ex, ey);
|
|
233
|
+
upFace = null;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (downFace && !downFaceExposed) {
|
|
237
|
+
const newQuad = Quad.Create(
|
|
238
|
+
[
|
|
239
|
+
[downFace[0] * factor, y * factor, 0],
|
|
240
|
+
[x * factor, y * factor, factor],
|
|
241
|
+
],
|
|
242
|
+
Quad.FullUVs as any,
|
|
243
|
+
false,
|
|
244
|
+
1
|
|
245
|
+
);
|
|
246
|
+
GeometryBuilder.addQuad(tool, origin, newQuad);
|
|
247
|
+
let [sx, sy] = downFace;
|
|
248
|
+
let [ex, ey] = [x, y];
|
|
249
|
+
ey += 1;
|
|
250
|
+
addUvs(sx, sy, ex, ey);
|
|
251
|
+
downFace = null;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const isPixel = isSolid(x, y);
|
|
255
|
+
if (!isSolid(x, y + 1) && !upFace && isPixel) {
|
|
256
|
+
upFace = [x, y];
|
|
257
|
+
}
|
|
258
|
+
if (!isSolid(x, y - 1) && !downFace && isPixel) {
|
|
259
|
+
downFace = [x, y];
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
for (const [key, [data]] of tool.mesh!.attributes) {
|
|
265
|
+
if (key == "position") {
|
|
266
|
+
for (let i = 0; i < data.length; i += 3) {
|
|
267
|
+
(data as any as number[])[i] -= 0.5;
|
|
268
|
+
(data as any as number[])[i + 1] -= 0.5;
|
|
269
|
+
(data as any as number[])[i + 2];
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
const compacted = CompactMesh("dve_item", tool);
|
|
275
|
+
*/
|
|
276
|
+
// return tool.mesh;
|
|
277
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ProtoMesh } from "../../Geomtry/Proto/ProtoMesh";
|
|
2
|
+
import { Vec3Array, Vector3Like } from "@amodx/math";
|
|
3
|
+
declare class ItemVars {
|
|
4
|
+
textureIndex: number;
|
|
5
|
+
reset(): void;
|
|
6
|
+
}
|
|
7
|
+
export declare class ItemModelBuilder {
|
|
8
|
+
id: string;
|
|
9
|
+
/**The current world position */
|
|
10
|
+
position: Vector3Like;
|
|
11
|
+
/**The current local origin */
|
|
12
|
+
origin: Vector3Like;
|
|
13
|
+
mesh: ProtoMesh;
|
|
14
|
+
vars: ItemVars;
|
|
15
|
+
bounds: {
|
|
16
|
+
min: Vec3Array;
|
|
17
|
+
max: Vec3Array;
|
|
18
|
+
};
|
|
19
|
+
_indexStart: number;
|
|
20
|
+
constructor(id: string);
|
|
21
|
+
startConstruction(): void;
|
|
22
|
+
endConstruction(): boolean;
|
|
23
|
+
_boundsUpdate: boolean;
|
|
24
|
+
updateBounds(bounds: [Vec3Array, Vec3Array]): void;
|
|
25
|
+
clear(): this;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ProtoMesh } from "../../Geomtry/Proto/ProtoMesh";
|
|
2
|
+
import { Vector3Like } from "@amodx/math";
|
|
3
|
+
import { ItemMeshVertexStructCursor } from "../Geomtry/ItemMeshVertexStructCursor";
|
|
4
|
+
class ItemVars {
|
|
5
|
+
textureIndex = 0;
|
|
6
|
+
reset() {
|
|
7
|
+
this.textureIndex = 0;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export class ItemModelBuilder {
|
|
11
|
+
id;
|
|
12
|
+
/**The current world position */
|
|
13
|
+
position = Vector3Like.Create();
|
|
14
|
+
/**The current local origin */
|
|
15
|
+
origin = Vector3Like.Create();
|
|
16
|
+
mesh = new ProtoMesh(ItemMeshVertexStructCursor.VertexFloatSize);
|
|
17
|
+
vars = new ItemVars();
|
|
18
|
+
bounds = {
|
|
19
|
+
min: [0, 0, 0],
|
|
20
|
+
max: [0, 0, 0],
|
|
21
|
+
};
|
|
22
|
+
_indexStart = 0;
|
|
23
|
+
constructor(id) {
|
|
24
|
+
this.id = id;
|
|
25
|
+
}
|
|
26
|
+
startConstruction() {
|
|
27
|
+
this._indexStart = this.mesh.indicieCount;
|
|
28
|
+
this.bounds.min[0] = Infinity;
|
|
29
|
+
this.bounds.min[1] = Infinity;
|
|
30
|
+
this.bounds.min[2] = Infinity;
|
|
31
|
+
this.bounds.max[0] = -Infinity;
|
|
32
|
+
this.bounds.max[1] = -Infinity;
|
|
33
|
+
this.bounds.max[2] = -Infinity;
|
|
34
|
+
this._boundsUpdate = false;
|
|
35
|
+
}
|
|
36
|
+
endConstruction() {
|
|
37
|
+
this.vars.reset();
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
_boundsUpdate = false;
|
|
41
|
+
updateBounds(bounds) {
|
|
42
|
+
const origin = this.origin;
|
|
43
|
+
//min
|
|
44
|
+
if (origin.x + bounds[0][0] < this.bounds.min[0])
|
|
45
|
+
this.bounds.min[0] = origin.x + bounds[0][0];
|
|
46
|
+
if (origin.y + bounds[0][1] < this.bounds.min[1])
|
|
47
|
+
this.bounds.min[1] = origin.y + bounds[0][1];
|
|
48
|
+
if (origin.z + bounds[0][2] < this.bounds.min[2])
|
|
49
|
+
this.bounds.min[2] = origin.z + bounds[0][2];
|
|
50
|
+
//max
|
|
51
|
+
if (origin.x + bounds[1][0] > this.bounds.max[0])
|
|
52
|
+
this.bounds.max[0] = origin.x + bounds[1][0];
|
|
53
|
+
if (origin.y + bounds[1][1] > this.bounds.max[1])
|
|
54
|
+
this.bounds.max[1] = origin.y + bounds[1][1];
|
|
55
|
+
if (origin.z + bounds[1][2] > this.bounds.max[2])
|
|
56
|
+
this.bounds.max[2] = origin.z + bounds[1][2];
|
|
57
|
+
this._boundsUpdate = true;
|
|
58
|
+
}
|
|
59
|
+
clear() {
|
|
60
|
+
this.vars.reset();
|
|
61
|
+
this.mesh.clear();
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -7,12 +7,18 @@ export type CompactSubMesh = [
|
|
|
7
7
|
minBounds: Vec3Array,
|
|
8
8
|
maxBounds: Vec3Array
|
|
9
9
|
];
|
|
10
|
-
export type CompactMeshData =
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
export type CompactMeshData = CompactSubMesh[];
|
|
11
|
+
/**
|
|
12
|
+
* old web gpu data
|
|
13
|
+
[
|
|
14
|
+
type: 1,
|
|
15
|
+
vertexBuffer: ArrayBuffer,
|
|
16
|
+
indexBuffer: Uint32Array,
|
|
17
|
+
bvhTreeBuffer: Float32Array,
|
|
18
|
+
bvhIndexBuffer: Uint32Array,
|
|
19
|
+
minBounds: Vec3Array,
|
|
20
|
+
maxBounds: Vec3Array,
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
@@ -3,12 +3,13 @@ export class VoxelMeshTypes {
|
|
|
3
3
|
static vertexStrideFloats = 24;
|
|
4
4
|
static VoxelMeshStructWGSL = /* wgsl */ `
|
|
5
5
|
struct VoxelMeshVertex {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
position: vec3f,
|
|
7
|
+
normal: vec3f,
|
|
8
|
+
textureIndex: vec3f,
|
|
9
|
+
uv: vec2f,
|
|
10
|
+
colors: vec3f,
|
|
11
|
+
voxelData: f32,
|
|
12
|
+
_padding: vec4f
|
|
12
13
|
};
|
|
13
14
|
`;
|
|
14
15
|
}
|