@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
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { StringPalette } from "../../Util/StringPalette";
|
|
2
|
-
import { VoxelRuleGeometry } from "./Classes/VoxelRulesGeometry";
|
|
3
|
-
import { VoxelRulesModoel } from "./Classes/VoxelRulesModel";
|
|
4
|
-
const addGeo = (modelId, stateId, nodes) => {
|
|
5
|
-
const registred = [];
|
|
6
|
-
for (const geoLinkNode of nodes) {
|
|
7
|
-
const geo = VoxelModelManager.geometry.get(geoLinkNode.geometryId);
|
|
8
|
-
if (!geo)
|
|
9
|
-
throw new Error(`Geometry ${geoLinkNode.geometryId} is not registered.`);
|
|
10
|
-
const newId = getGeometryLinkId(geoLinkNode);
|
|
11
|
-
if (VoxelModelManager.geometry.has(newId))
|
|
12
|
-
continue;
|
|
13
|
-
registred.push([stateId, newId]);
|
|
14
|
-
if (!VoxelModelManager.geometryPalette.isRegistered(newId))
|
|
15
|
-
VoxelModelManager.geometryPalette.register(newId);
|
|
16
|
-
const newData = structuredClone(geo.data);
|
|
17
|
-
newData.nodes = newData.nodes.map((_) => ({
|
|
18
|
-
..._,
|
|
19
|
-
tranform: {
|
|
20
|
-
...(geoLinkNode.position ? { position: geoLinkNode.position } : {}),
|
|
21
|
-
...(geoLinkNode.scale ? { scale: geoLinkNode.scale } : {}),
|
|
22
|
-
...(geoLinkNode.rotation ? { rotation: geoLinkNode.rotation } : {}),
|
|
23
|
-
...(geoLinkNode.rotationPivot
|
|
24
|
-
? { rotationPivot: geoLinkNode.rotationPivot }
|
|
25
|
-
: {}),
|
|
26
|
-
...(geoLinkNode.flip ? { flip: geoLinkNode.flip } : {}),
|
|
27
|
-
},
|
|
28
|
-
}));
|
|
29
|
-
VoxelModelManager.geometry.set(newId, new VoxelRuleGeometry(newId, newData));
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
return registred;
|
|
33
|
-
};
|
|
34
|
-
const getGeometryLinkId = (node) => {
|
|
35
|
-
return `${node.geometryId}${node.position ? `-p${node.position.toString()}` : ""}${node.rotation ? `-r${node.rotation.toString()}` : ""}${node.scale ? `-s${node.scale.toString()}` : ""}`.trim();
|
|
36
|
-
};
|
|
37
|
-
export class VoxelModelManager {
|
|
38
|
-
static geometryPalette = new StringPalette();
|
|
39
|
-
static getGeometryLinkId = getGeometryLinkId;
|
|
40
|
-
static voxels = new Map();
|
|
41
|
-
static geometry = new Map();
|
|
42
|
-
static models = new Map();
|
|
43
|
-
static registerGeometry(...geometry) {
|
|
44
|
-
for (const geo of geometry) {
|
|
45
|
-
if (!this.geometryPalette.isRegistered(geo.id))
|
|
46
|
-
this.geometryPalette.register(geo.id);
|
|
47
|
-
this.geometry.set(geo.id, new VoxelRuleGeometry(geo.id, {
|
|
48
|
-
ogData: geo,
|
|
49
|
-
id: geo.id,
|
|
50
|
-
nodes: geo.nodes.map((node) => ({
|
|
51
|
-
node,
|
|
52
|
-
tranform: {},
|
|
53
|
-
})),
|
|
54
|
-
}));
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
static getGeomtryFromLink(link) {
|
|
58
|
-
return this.geometry.get(getGeometryLinkId(link));
|
|
59
|
-
}
|
|
60
|
-
static registerModels(...models) {
|
|
61
|
-
for (const model of models) {
|
|
62
|
-
const rulesModel = new VoxelRulesModoel(model);
|
|
63
|
-
this.models.set(model.id, rulesModel);
|
|
64
|
-
for (const stateId in model.shapeStatesNodes) {
|
|
65
|
-
const nodes = model.shapeStatesNodes[stateId];
|
|
66
|
-
addGeo(model.id, stateId, nodes).forEach((_) => rulesModel.registerShapeState(..._));
|
|
67
|
-
}
|
|
68
|
-
for (const stateId in model.shapeStatesConditonalNodes) {
|
|
69
|
-
const nodes = model.shapeStatesConditonalNodes[stateId];
|
|
70
|
-
addGeo(model.id, stateId, nodes).forEach((_) => rulesModel.registerCondiotnalNode(..._));
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
static registerVoxel(id, data) {
|
|
75
|
-
let voxelModels = this.voxels.get(data.id);
|
|
76
|
-
if (!voxelModels) {
|
|
77
|
-
voxelModels = [];
|
|
78
|
-
this.voxels.set(data.id, voxelModels);
|
|
79
|
-
}
|
|
80
|
-
voxelModels.push({ id, data });
|
|
81
|
-
}
|
|
82
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { LocationData } from "../../../../Math/index.js";
|
|
2
|
-
import { DimensionSegment } from "./DimensionSegment.js";
|
|
3
|
-
export type IWGTasksData = {
|
|
4
|
-
id: string;
|
|
5
|
-
propagationBlocking?: boolean;
|
|
6
|
-
run(location: LocationData, onDone: () => void, dimension: DimensionSegment): void;
|
|
7
|
-
};
|
|
8
|
-
export declare class IWGTaskBase {
|
|
9
|
-
data: IWGTasksData;
|
|
10
|
-
constructor(data: IWGTasksData);
|
|
11
|
-
add(dimensionId: string, x: number, y: number, z: number): void;
|
|
12
|
-
remove(dimensionId: string, x: number, y: number, z: number): void;
|
|
13
|
-
cancelAll(dimensionId?: string | null): void;
|
|
14
|
-
runTask(max?: number): void;
|
|
15
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { DimensionSegment } from "./Classes/DimensionSegment";
|
|
2
|
-
export declare class IWGDimensions {
|
|
3
|
-
static readonly _dimensions: Map<string, DimensionSegment>;
|
|
4
|
-
static addDimension(dimensionId: string): void;
|
|
5
|
-
static getDimension(dimensionId: string): DimensionSegment;
|
|
6
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export declare class IWGTasks {
|
|
2
|
-
/**# Load Sectors
|
|
3
|
-
* ---
|
|
4
|
-
*/
|
|
5
|
-
static readonly worldLoadTasks: import("./Classes/IWGTaskBase").IWGTaskBase;
|
|
6
|
-
/**# Generate Sectors
|
|
7
|
-
* ---
|
|
8
|
-
*/
|
|
9
|
-
static readonly worldGenTasks: import("./Classes/IWGTaskBase").IWGTaskBase;
|
|
10
|
-
/**# Decorate Sectors
|
|
11
|
-
* ---
|
|
12
|
-
*/
|
|
13
|
-
static readonly worldDecorateTasks: import("./Classes/IWGTaskBase").IWGTaskBase;
|
|
14
|
-
/**# World Sun
|
|
15
|
-
* ---
|
|
16
|
-
*/
|
|
17
|
-
static readonly worldSunTasks: import("./Classes/IWGTaskBase").IWGTaskBase;
|
|
18
|
-
/**# World Propagation
|
|
19
|
-
* ---
|
|
20
|
-
*/
|
|
21
|
-
static readonly worldPropagationTasks: import("./Classes/IWGTaskBase").IWGTaskBase;
|
|
22
|
-
/**# Save Sector
|
|
23
|
-
* ---
|
|
24
|
-
*/
|
|
25
|
-
static readonly saveTasks: import("./Classes/IWGTaskBase").IWGTaskBase;
|
|
26
|
-
/**# Save & Unload Sector
|
|
27
|
-
* ---
|
|
28
|
-
*/
|
|
29
|
-
static readonly saveAndUnloadTasks: import("./Classes/IWGTaskBase").IWGTaskBase;
|
|
30
|
-
/**# Build Task
|
|
31
|
-
* ---
|
|
32
|
-
*/
|
|
33
|
-
static readonly buildTasks: import("./Classes/IWGTaskBase").IWGTaskBase;
|
|
34
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Thread } from "@amodx/threads";
|
|
2
|
-
import { TaskTool } from "../../../Tools/Tasks/TasksTool";
|
|
3
|
-
import { WorldStorageInterface } from "../../../World/Storage/WorldStorage.interface";
|
|
4
|
-
export declare class IWGTools {
|
|
5
|
-
static taskTool: TaskTool;
|
|
6
|
-
static worldStorage: WorldStorageInterface | null;
|
|
7
|
-
static parent: Thread;
|
|
8
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
export const TextureAnimationCreator = {
|
|
2
|
-
createAnimations(texture) {
|
|
3
|
-
if (!texture.paths.size)
|
|
4
|
-
return;
|
|
5
|
-
const animaitonUniform = [];
|
|
6
|
-
let i = 0;
|
|
7
|
-
for (const anim of texture.animationsMap) {
|
|
8
|
-
animaitonUniform[anim[0]] = anim[0];
|
|
9
|
-
let keyCounts = [];
|
|
10
|
-
const animTime = texture.animationTimes[i];
|
|
11
|
-
if (animTime.length == 1) {
|
|
12
|
-
for (let k = 0; k < anim.length; k++) {
|
|
13
|
-
keyCounts.push(animTime[0]);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
keyCounts = texture.animationTimes[i];
|
|
18
|
-
}
|
|
19
|
-
texture.animations.push({
|
|
20
|
-
uniformIndex: anim[0],
|
|
21
|
-
keys: anim,
|
|
22
|
-
currentFrame: 0,
|
|
23
|
-
currentCount: 0,
|
|
24
|
-
keyCounts: keyCounts,
|
|
25
|
-
});
|
|
26
|
-
i++;
|
|
27
|
-
}
|
|
28
|
-
for (let i = 0; i < texture.totalTextures; i++) {
|
|
29
|
-
if (!animaitonUniform[i]) {
|
|
30
|
-
animaitonUniform[i] = 0;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
texture.animationUniform = new Float32Array(animaitonUniform);
|
|
34
|
-
},
|
|
35
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import type { TextureData } from "./Texture.types";
|
|
2
|
-
export declare class TextureArray {
|
|
3
|
-
id: string;
|
|
4
|
-
extension: string;
|
|
5
|
-
totalTextures: number;
|
|
6
|
-
textureMap: Map<string, TextureData>;
|
|
7
|
-
textures: TextureData[];
|
|
8
|
-
textureIndex: Record<string, number>;
|
|
9
|
-
animationsMap: number[][];
|
|
10
|
-
animationTimes: number[][];
|
|
11
|
-
animations: {
|
|
12
|
-
uniformIndex: number;
|
|
13
|
-
overlay?: boolean;
|
|
14
|
-
keys: number[];
|
|
15
|
-
currentFrame: number;
|
|
16
|
-
currentCount: number;
|
|
17
|
-
keyCounts: number[];
|
|
18
|
-
}[];
|
|
19
|
-
varyingID: string;
|
|
20
|
-
animationUniforID: string;
|
|
21
|
-
animationUniform: Float32Array;
|
|
22
|
-
paths: Map<string, HTMLImageElement | string | false>;
|
|
23
|
-
images: HTMLImageElement[];
|
|
24
|
-
shaderTexture: any | null;
|
|
25
|
-
textureID: string;
|
|
26
|
-
attributeID: string;
|
|
27
|
-
constructor(id: string);
|
|
28
|
-
/**# clearData
|
|
29
|
-
* ---
|
|
30
|
-
* Clear all un-needed data.
|
|
31
|
-
*/
|
|
32
|
-
clearData(): void;
|
|
33
|
-
/**# flush
|
|
34
|
-
* ---
|
|
35
|
-
* Clear all data.
|
|
36
|
-
*/
|
|
37
|
-
flush(): void;
|
|
38
|
-
flushAll(): void;
|
|
39
|
-
build(): Promise<void>;
|
|
40
|
-
getTextureIndex(textureId: string, varation?: string): number;
|
|
41
|
-
addTexture(data: TextureData): void;
|
|
42
|
-
runAnimations(): void;
|
|
43
|
-
getTextureIndexMap(): Record<string, number>;
|
|
44
|
-
_processVariations(textureData: TextureData, paths: Map<string, HTMLImageElement | string | false>, map: Record<string, number>, animations: number[][], textureAnimatioTimes: number[][], extension: string, count: number): number;
|
|
45
|
-
_getPath(textureData: TextureData, varation: string | undefined, extension: string): string;
|
|
46
|
-
buildTextureIndex(): false | undefined;
|
|
47
|
-
}
|
package/Textures/TextureArray.js
DELETED
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
import { TextureManager } from "./TextureManager.js";
|
|
2
|
-
import { TextureAnimationCreator } from "./TextureAnimations.js";
|
|
3
|
-
import { TextureBuilder } from "./TextureBuilder.js";
|
|
4
|
-
export class TextureArray {
|
|
5
|
-
id;
|
|
6
|
-
extension = "png";
|
|
7
|
-
totalTextures = 0;
|
|
8
|
-
textureMap = new Map();
|
|
9
|
-
textures = [];
|
|
10
|
-
textureIndex = {};
|
|
11
|
-
animationsMap = [];
|
|
12
|
-
animationTimes = [];
|
|
13
|
-
animations = [];
|
|
14
|
-
varyingID = "";
|
|
15
|
-
animationUniforID = "";
|
|
16
|
-
animationUniform = new Float32Array();
|
|
17
|
-
paths = new Map();
|
|
18
|
-
images = [];
|
|
19
|
-
/* actual renderer resource */
|
|
20
|
-
shaderTexture = null;
|
|
21
|
-
textureID = "";
|
|
22
|
-
attributeID = "textureIndex";
|
|
23
|
-
constructor(id) {
|
|
24
|
-
this.id = id;
|
|
25
|
-
this.textureID = id.replace("#", "");
|
|
26
|
-
}
|
|
27
|
-
/**# clearData
|
|
28
|
-
* ---
|
|
29
|
-
* Clear all un-needed data.
|
|
30
|
-
*/
|
|
31
|
-
clearData() {
|
|
32
|
-
this.paths.clear();
|
|
33
|
-
this.textures = [];
|
|
34
|
-
this.textureMap.clear();
|
|
35
|
-
this.textureIndex = {};
|
|
36
|
-
this.images = [];
|
|
37
|
-
this.animationsMap = [];
|
|
38
|
-
this.animationTimes = [];
|
|
39
|
-
}
|
|
40
|
-
/**# flush
|
|
41
|
-
* ---
|
|
42
|
-
* Clear all data.
|
|
43
|
-
*/
|
|
44
|
-
flush() {
|
|
45
|
-
this.clearData();
|
|
46
|
-
this.images = [];
|
|
47
|
-
this.animations = [];
|
|
48
|
-
this.animationTimes = [];
|
|
49
|
-
this.animationsMap = [];
|
|
50
|
-
this.textureIndex = {};
|
|
51
|
-
this.totalTextures = 0;
|
|
52
|
-
}
|
|
53
|
-
flushAll() {
|
|
54
|
-
// this.materials.clear();
|
|
55
|
-
}
|
|
56
|
-
async build() {
|
|
57
|
-
this.buildTextureIndex();
|
|
58
|
-
if (this.paths.size) {
|
|
59
|
-
this.images = await TextureBuilder.createMaterialTexture(this.id, this.paths);
|
|
60
|
-
}
|
|
61
|
-
TextureAnimationCreator.createAnimations(this);
|
|
62
|
-
}
|
|
63
|
-
getTextureIndex(textureId, varation = "") {
|
|
64
|
-
let id = textureId;
|
|
65
|
-
if (varation) {
|
|
66
|
-
id = `${textureId}:${varation}`;
|
|
67
|
-
}
|
|
68
|
-
let uv = -1;
|
|
69
|
-
uv = this.textureIndex[id];
|
|
70
|
-
if (uv == -1) {
|
|
71
|
-
throw new Error(`Texture with id: ${id} does not exists.typeId : ${this.id} `);
|
|
72
|
-
}
|
|
73
|
-
return uv;
|
|
74
|
-
}
|
|
75
|
-
addTexture(data) {
|
|
76
|
-
this.textures.push(data);
|
|
77
|
-
this.textureMap.set(data.id, data);
|
|
78
|
-
}
|
|
79
|
-
runAnimations() {
|
|
80
|
-
for (let i = 0; i < this.animations.length; i++) {
|
|
81
|
-
const anim = this.animations[i];
|
|
82
|
-
if (anim.currentCount <= anim.keyCounts[anim.currentFrame]) {
|
|
83
|
-
anim.currentCount++;
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
anim.currentCount = 0;
|
|
87
|
-
if (anim.currentFrame < anim.keys.length - 1) {
|
|
88
|
-
anim.currentFrame++;
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
anim.currentFrame = 0;
|
|
92
|
-
}
|
|
93
|
-
this.animationUniform[anim.uniformIndex] = anim.keys[anim.currentFrame];
|
|
94
|
-
/* for (const [key, material] of this.materials) {
|
|
95
|
-
material!.setNumberArray(
|
|
96
|
-
this.animationUniforID,
|
|
97
|
-
this.animationUniform as any
|
|
98
|
-
);
|
|
99
|
-
} */
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
getTextureIndexMap() {
|
|
103
|
-
return this.textureIndex;
|
|
104
|
-
}
|
|
105
|
-
_processVariations(textureData, paths, map, animations, textureAnimatioTimes, extension, count) {
|
|
106
|
-
if (!textureData.variations)
|
|
107
|
-
return count;
|
|
108
|
-
for (const varation of Object.keys(textureData.variations)) {
|
|
109
|
-
const data = textureData.variations[varation];
|
|
110
|
-
if (data.frames == 0) {
|
|
111
|
-
map[`${textureData.id}:${varation}`] = count;
|
|
112
|
-
const assetPath = this._getPath(textureData, varation, extension);
|
|
113
|
-
let raw = false;
|
|
114
|
-
if (data.base64 && !Array.isArray(data.base64)) {
|
|
115
|
-
raw = data.base64;
|
|
116
|
-
}
|
|
117
|
-
paths.set(assetPath, raw);
|
|
118
|
-
count++;
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
if (!data.animKeys)
|
|
122
|
-
throw new Error("Texture Varation must have supplied animKeys if frames are greater than 0.");
|
|
123
|
-
for (let i = 1; i <= data.frames; i++) {
|
|
124
|
-
map[`${textureData.id}:${varation}-${i}`] = count;
|
|
125
|
-
const assetPath = this._getPath(textureData, `${varation}-${i}`, extension);
|
|
126
|
-
let raw = false;
|
|
127
|
-
if (data.base64) {
|
|
128
|
-
raw = data.base64[i - 1];
|
|
129
|
-
}
|
|
130
|
-
paths.set(assetPath, raw);
|
|
131
|
-
count++;
|
|
132
|
-
}
|
|
133
|
-
const trueKeys = [];
|
|
134
|
-
for (let i = 0; i < data.animKeys.length; i++) {
|
|
135
|
-
trueKeys.push(map[`${textureData.id}:${varation}-${data.animKeys[i]}`]);
|
|
136
|
-
}
|
|
137
|
-
if (data.animKeyFrameTimes) {
|
|
138
|
-
textureAnimatioTimes.push(data.animKeyFrameTimes);
|
|
139
|
-
}
|
|
140
|
-
if (data.globalFrameTime) {
|
|
141
|
-
textureAnimatioTimes.push([data.globalFrameTime]);
|
|
142
|
-
}
|
|
143
|
-
animations.push(trueKeys);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
return count;
|
|
147
|
-
}
|
|
148
|
-
_getPath(textureData, varation = "default", extension) {
|
|
149
|
-
return `${textureData.path ? textureData.path : TextureManager.defaultTexturePath}/${textureData.id}/${varation}.${extension}`;
|
|
150
|
-
}
|
|
151
|
-
buildTextureIndex() {
|
|
152
|
-
const texture = this;
|
|
153
|
-
if (!texture)
|
|
154
|
-
return false;
|
|
155
|
-
const extension = texture.extension;
|
|
156
|
-
let count = 0;
|
|
157
|
-
const map = this.textureIndex;
|
|
158
|
-
const paths = this.paths;
|
|
159
|
-
const animationTimes = this.animationTimes;
|
|
160
|
-
const animations = this.animationsMap;
|
|
161
|
-
for (const textureData of this.textures) {
|
|
162
|
-
if (textureData.frames == 0) {
|
|
163
|
-
this.textureIndex[`${textureData.id}`] = count;
|
|
164
|
-
const assetPath = this._getPath(textureData, "default", extension);
|
|
165
|
-
let raw = false;
|
|
166
|
-
if (textureData.base64 && !Array.isArray(textureData.base64)) {
|
|
167
|
-
raw = textureData.base64;
|
|
168
|
-
}
|
|
169
|
-
paths.set(assetPath, raw);
|
|
170
|
-
count++;
|
|
171
|
-
count = this._processVariations(textureData, paths, map, animations, animationTimes, extension, count);
|
|
172
|
-
}
|
|
173
|
-
else {
|
|
174
|
-
if (!textureData.animKeys)
|
|
175
|
-
throw new Error("Texture must have supplied animKeys if frames are greater than 0.");
|
|
176
|
-
const rawData = textureData.rawData;
|
|
177
|
-
for (let i = 1; i <= textureData.frames; i++) {
|
|
178
|
-
const assetPath = this._getPath(textureData, `default-${i}`, extension);
|
|
179
|
-
let raw = false;
|
|
180
|
-
if (textureData.base64) {
|
|
181
|
-
raw = textureData.base64[i - 1];
|
|
182
|
-
}
|
|
183
|
-
paths.set(assetPath, raw);
|
|
184
|
-
count++;
|
|
185
|
-
}
|
|
186
|
-
const trueKeys = [];
|
|
187
|
-
for (let i = 0; i < textureData.animKeys.length; i++) {
|
|
188
|
-
trueKeys.push(map[`${textureData.id}:default-${textureData.animKeys[i]}`]);
|
|
189
|
-
}
|
|
190
|
-
if (textureData.animKeyFrameTimes) {
|
|
191
|
-
animationTimes.push(textureData.animKeyFrameTimes);
|
|
192
|
-
}
|
|
193
|
-
if (textureData.globalFrameTime) {
|
|
194
|
-
animationTimes.push([textureData.globalFrameTime]);
|
|
195
|
-
}
|
|
196
|
-
animations.push(trueKeys);
|
|
197
|
-
count = this._processVariations(textureData, paths, map, animations, animationTimes, extension, count);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
this.totalTextures = count;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export declare class TextureBuilder {
|
|
2
|
-
static context: CanvasRenderingContext2D | null;
|
|
3
|
-
static _textureSize: number;
|
|
4
|
-
static finalImagWidth: number;
|
|
5
|
-
static finalImageHeight: number;
|
|
6
|
-
static _canvas: HTMLCanvasElement;
|
|
7
|
-
static defineTextureDimensions(textureSize: number): void;
|
|
8
|
-
static setUpImageCreation(): void;
|
|
9
|
-
static createMaterialTexture(name: string, images: Map<string, HTMLImageElement | string | false>, width?: number, height?: number): Promise<HTMLImageElement[]>;
|
|
10
|
-
static getRawData(imageSrc: string): Promise<Uint8ClampedArray>;
|
|
11
|
-
static getBase64(imageSrc: string): Promise<string>;
|
|
12
|
-
static loadImage(imgSrcData: string | HTMLImageElement, width?: number, height?: number): Promise<HTMLImageElement>;
|
|
13
|
-
}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
export class TextureBuilder {
|
|
2
|
-
static context = null;
|
|
3
|
-
static _textureSize = 16;
|
|
4
|
-
static finalImagWidth = 16;
|
|
5
|
-
static finalImageHeight = 16;
|
|
6
|
-
static _canvas = document.createElement("canvas");
|
|
7
|
-
static defineTextureDimensions(textureSize) {
|
|
8
|
-
this.finalImagWidth = textureSize < 256 ? 256 : textureSize;
|
|
9
|
-
this.finalImageHeight = textureSize < 256 ? 256 : textureSize;
|
|
10
|
-
this._textureSize = textureSize;
|
|
11
|
-
}
|
|
12
|
-
static setUpImageCreation() {
|
|
13
|
-
this._canvas.width = this.finalImagWidth;
|
|
14
|
-
this._canvas.height = this.finalImageHeight;
|
|
15
|
-
const context = this._canvas.getContext("2d", { willReadFrequently: true });
|
|
16
|
-
if (!context) {
|
|
17
|
-
throw new Error("Context did not load for texture creation.");
|
|
18
|
-
}
|
|
19
|
-
document.body.append(this._canvas);
|
|
20
|
-
/* this._canvas.setAttribute(
|
|
21
|
-
"style",
|
|
22
|
-
`
|
|
23
|
-
image-rendering: pixelated;
|
|
24
|
-
position: absolute;
|
|
25
|
-
border: 1px solid red;
|
|
26
|
-
z-index: 1000;
|
|
27
|
-
top: 0;
|
|
28
|
-
`
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
*/
|
|
32
|
-
this.context = context;
|
|
33
|
-
}
|
|
34
|
-
static async createMaterialTexture(name, images, width = -1, height = -1) {
|
|
35
|
-
if (width == -1)
|
|
36
|
-
width = this.finalImagWidth;
|
|
37
|
-
if (height == -1)
|
|
38
|
-
height = this.finalImageHeight;
|
|
39
|
-
this._canvas.width = this.finalImagWidth;
|
|
40
|
-
this._canvas.height = this.finalImageHeight;
|
|
41
|
-
const resolvedImages = [];
|
|
42
|
-
for (const [path, rawData] of images) {
|
|
43
|
-
const data = await this.loadImage(rawData ? rawData : path, width, height);
|
|
44
|
-
resolvedImages.push(data);
|
|
45
|
-
}
|
|
46
|
-
return resolvedImages;
|
|
47
|
-
}
|
|
48
|
-
static async getRawData(imageSrc) {
|
|
49
|
-
return new Promise((resolve, reject) => {
|
|
50
|
-
const image = new Image();
|
|
51
|
-
image.crossOrigin = "Anonymous";
|
|
52
|
-
image.src = imageSrc;
|
|
53
|
-
image.onload = () => {
|
|
54
|
-
if (!this.context) {
|
|
55
|
-
return reject(new Error("Context is not set for texture creation."));
|
|
56
|
-
}
|
|
57
|
-
this._canvas.width = image.width;
|
|
58
|
-
this._canvas.height = image.height;
|
|
59
|
-
this.context.clearRect(0, 0, image.width, image.height);
|
|
60
|
-
this.context.drawImage(image, 0, 0, image.width, image.height);
|
|
61
|
-
const imgData = this.context.getImageData(0, 0, image.width, image.height);
|
|
62
|
-
resolve(imgData.data);
|
|
63
|
-
this._canvas.width = this.finalImagWidth;
|
|
64
|
-
this._canvas.height = this.finalImageHeight;
|
|
65
|
-
};
|
|
66
|
-
image.onerror = (err) => reject(err);
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
static async getBase64(imageSrc) {
|
|
70
|
-
return new Promise((resolve, reject) => {
|
|
71
|
-
const image = new Image();
|
|
72
|
-
image.crossOrigin = "Anonymous";
|
|
73
|
-
image.src = imageSrc;
|
|
74
|
-
image.onload = () => {
|
|
75
|
-
if (!this.context) {
|
|
76
|
-
return reject(new Error("Context is not set for texture creation."));
|
|
77
|
-
}
|
|
78
|
-
this._canvas.width = image.width;
|
|
79
|
-
this._canvas.height = image.height;
|
|
80
|
-
this.context.clearRect(0, 0, image.width, image.height);
|
|
81
|
-
this.context.drawImage(image, 0, 0, image.width, image.height);
|
|
82
|
-
resolve(this._canvas.toDataURL("image/png"));
|
|
83
|
-
this._canvas.width = this.finalImagWidth;
|
|
84
|
-
this._canvas.height = this.finalImageHeight;
|
|
85
|
-
};
|
|
86
|
-
image.onerror = (err) => reject(err);
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
static async loadImage(imgSrcData, width = 0, height = 0) {
|
|
90
|
-
if (!width)
|
|
91
|
-
width = this.finalImagWidth;
|
|
92
|
-
if (!height)
|
|
93
|
-
height = this.finalImageHeight;
|
|
94
|
-
const ctx = TextureBuilder.context;
|
|
95
|
-
if (!ctx) {
|
|
96
|
-
throw new Error("Context is not set for texture creation.");
|
|
97
|
-
}
|
|
98
|
-
const prom = new Promise((resolve) => {
|
|
99
|
-
const image = typeof imgSrcData == "string" ? new Image() : imgSrcData;
|
|
100
|
-
if (typeof imgSrcData == "string")
|
|
101
|
-
image.src = imgSrcData;
|
|
102
|
-
image.onload = () => {
|
|
103
|
-
ctx.clearRect(0, 0, this._canvas.width, this._canvas.height);
|
|
104
|
-
ctx.imageSmoothingEnabled = false;
|
|
105
|
-
ctx.save();
|
|
106
|
-
ctx.translate(0, this._canvas.height);
|
|
107
|
-
ctx.scale(1, -1);
|
|
108
|
-
ctx.drawImage(image, 0, 0, this._canvas.width, this._canvas.height);
|
|
109
|
-
ctx.restore();
|
|
110
|
-
const dataUrl = this._canvas.toDataURL("image/png");
|
|
111
|
-
const returnImage = new Image(this._canvas.width, this._canvas.height);
|
|
112
|
-
returnImage.src = dataUrl;
|
|
113
|
-
returnImage.onload = () => {
|
|
114
|
-
resolve(returnImage);
|
|
115
|
-
};
|
|
116
|
-
};
|
|
117
|
-
});
|
|
118
|
-
return prom;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { TextureTypeUVMap, TextureId } from "./Texture.types";
|
|
2
|
-
export declare class TextureRegister {
|
|
3
|
-
static textureDataHasBeenSet: boolean;
|
|
4
|
-
static data: TextureTypeUVMap;
|
|
5
|
-
static getTextureUV(data: TextureId): number;
|
|
6
|
-
static setTextureIndex(data: TextureTypeUVMap): void;
|
|
7
|
-
static releaseTextureData(): void;
|
|
8
|
-
static isReady(): boolean;
|
|
9
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export class TextureRegister {
|
|
2
|
-
static textureDataHasBeenSet = false;
|
|
3
|
-
static data;
|
|
4
|
-
static getTextureUV(data) {
|
|
5
|
-
const [textureType, textureId, varation] = data;
|
|
6
|
-
let id = textureId;
|
|
7
|
-
if (varation) {
|
|
8
|
-
id = `${textureId}:${varation}`;
|
|
9
|
-
}
|
|
10
|
-
let uv = -1;
|
|
11
|
-
uv = this.data[textureType][id];
|
|
12
|
-
if (uv == -1) {
|
|
13
|
-
throw new Error(`Texture with id: ${id} does not exists.`);
|
|
14
|
-
}
|
|
15
|
-
return uv;
|
|
16
|
-
}
|
|
17
|
-
static setTextureIndex(data) {
|
|
18
|
-
this.textureDataHasBeenSet = true;
|
|
19
|
-
this.data = data;
|
|
20
|
-
}
|
|
21
|
-
static releaseTextureData() {
|
|
22
|
-
this.data = null;
|
|
23
|
-
delete this["data"];
|
|
24
|
-
}
|
|
25
|
-
static isReady() {
|
|
26
|
-
return this.textureDataHasBeenSet;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { VoxelCursorInterface } from "../Voxels/Cursor/VoxelCursor.interface";
|
|
2
|
-
export declare abstract class DataCursorInterface {
|
|
3
|
-
abstract getVoxel(x: number, y: number, z: number): VoxelCursorInterface | null;
|
|
4
|
-
abstract inBounds(x: number, y: number, z: number): boolean;
|
|
5
|
-
}
|
package/Util/Binary/BitArray.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export function getBitValue(data, bitIndex, bitSize) {
|
|
2
|
-
const mask = 2 ** bitSize - 1;
|
|
3
|
-
return ((mask << bitIndex) & data) >>> bitIndex;
|
|
4
|
-
}
|
|
5
|
-
export function setBitValue(data, bitIndex, value, bitSize) {
|
|
6
|
-
const mask = 2 ** bitSize - 1;
|
|
7
|
-
return (data & ~(mask << bitIndex)) | ((value & mask) << bitIndex);
|
|
8
|
-
}
|
|
9
|
-
export function getBitArrayIndex(data, arrayIndex) {
|
|
10
|
-
const arrayByteIndex = (arrayIndex / 8) >> 0;
|
|
11
|
-
return getBitValue(data[arrayByteIndex], arrayIndex - arrayByteIndex * 8, 1);
|
|
12
|
-
}
|
|
13
|
-
export function setBitArrayIndex(data, arrayIndex, value) {
|
|
14
|
-
const arrayByteIndex = (arrayIndex / 8) >> 0;
|
|
15
|
-
data[arrayByteIndex] = setBitValue(data[arrayByteIndex], arrayIndex - arrayByteIndex * 8, value, 1);
|
|
16
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export var WorldDataStructProperties;
|
|
2
|
-
(function (WorldDataStructProperties) {
|
|
3
|
-
WorldDataStructProperties["header"] = "dve_header";
|
|
4
|
-
WorldDataStructProperties["dataType"] = "dve_data_type";
|
|
5
|
-
WorldDataStructProperties["dimensionId"] = "dve_dimension_id";
|
|
6
|
-
WorldDataStructProperties["positionX"] = "dve_p_x";
|
|
7
|
-
WorldDataStructProperties["positionY"] = "dve_p_y";
|
|
8
|
-
WorldDataStructProperties["positionZ"] = "dve_p_z";
|
|
9
|
-
})(WorldDataStructProperties || (WorldDataStructProperties = {}));
|
|
File without changes
|
|
File without changes
|
|
File without changes
|