Skip to content

Commit 5f5f73b

Browse files
authored
Version 1.0.3-alpha (#2)
* Refactor package structure and enhance dictionary array handling - Updated GitHub python workflows - Removed requirements.txt and setup.py, transitioning to pyproject.toml for package management. - Modified MANIFEST.in to exclude requirements.txt. - Added new properties and methods in Mesh class to support nested dictionary structures containing numpy arrays. - Implemented recursive extraction and reconstruction of nested arrays in MeshUtils. - Created comprehensive unit tests for dictionary fields containing arrays, ensuring correct encoding and decoding. - Added TypeScript tests for dictionary arrays, verifying functionality and data integrity. * Refactor mesh handling to support mixed polygon types and preserve non-array values in nested dictionaries - Updated EncodedMesh and Mesh classes to include index_sizes for polygon size metadata. - Introduced methods for polygon count and uniformity checks in MeshUtils. - Enhanced encoding/decoding processes to handle mixed polygon structures (triangles and quads). - Modified tests to validate the preservation of non-array values in nested dictionaries during encoding/decoding. - Adjusted ArrayUtils to support both Float32Array and Uint32Array. - Removed obsolete dictionary structure metadata handling from Mesh and MeshUtils. * Refactor mesh handling to support nested directory structure for encoded arrays and update related metadata management * Update Mesh class index_sizes validation and improve documentation for inferred sizes * Added deterministic zip output * Bump version to 1.0.3-alpha in pyproject.toml and package.json
1 parent bfa27d6 commit 5f5f73b

13 files changed

Lines changed: 1609 additions & 140 deletions

File tree

.github/workflows/pypi-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
python -m pip install --upgrade pip
1818
cd python
1919
pip install build
20-
pip install -r requirements.txt
20+
pip install .
2121
2222
- name: Build package
2323
run: cd python && python -m build --sdist

.github/workflows/python-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Install dependencies
2323
run: |
2424
python -m pip install --upgrade pip
25-
cd python && pip install -r requirements.txt
25+
cd python && pip install .
2626
- name: Test with unittest
2727
run: |
2828
cd python && python -m unittest discover tests

python/MANIFEST.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
include README.md
2-
include requirements.txt
32
include LICENSE

python/examples/mesh_example.ipynb

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,20 @@
5757
" \n",
5858
" # Add non-array attributes\n",
5959
" material_name: str = Field(\"default\", description=\"Material name\")\n",
60-
" tags: List[str] = Field(default_factory=list, description=\"Tags for the mesh\")"
60+
" tags: List[str] = Field(default_factory=list, description=\"Tags for the mesh\")\n",
61+
"\n",
62+
" # Dictionary containing nested dictionaries with arrays\n",
63+
" material_data: dict[str, dict[str, np.ndarray]] = Field(\n",
64+
" default_factory=dict,\n",
65+
" description=\"Nested dictionary structure with arrays\"\n",
66+
" )\n",
67+
"\n",
68+
" material_colors: dict[str, str] = Field(\n",
69+
" default_factory=dict,\n",
70+
" description=\"Dictionary with non-array values\"\n",
71+
" )\n",
72+
" \n",
73+
" \n"
6174
]
6275
},
6376
{
@@ -99,12 +112,12 @@
99112
"\n",
100113
"# Create indices for the cube\n",
101114
"indices = np.array([\n",
102-
" 0, 1, 2, 2, 3, 0, # back face\n",
103-
" 1, 5, 6, 6, 2, 1, # right face\n",
104-
" 5, 4, 7, 7, 6, 5, # front face\n",
105-
" 4, 0, 3, 3, 7, 4, # left face\n",
106-
" 3, 2, 6, 6, 7, 3, # top face\n",
107-
" 4, 5, 1, 1, 0, 4 # bottom face\n",
115+
" [0, 1, 2, 2, 3, 0], # back face\n",
116+
" [1, 5, 6, 6, 2, 1], # right face\n",
117+
" [5, 4, 7, 7, 6, 5], # front face\n",
118+
" [4, 0, 3, 3, 7, 4], # left face\n",
119+
" [3, 2, 6, 6, 7, 3], # top face\n",
120+
" [4, 5, 1, 1, 0, 4] # bottom face\n",
108121
"], dtype=np.uint32)\n",
109122
"\n",
110123
"# Create texture coordinates (one for each vertex)\n",
@@ -138,7 +151,17 @@
138151
" texture_coords=texture_coords,\n",
139152
" normals=normals,\n",
140153
" material_name=\"cube_material\",\n",
141-
" tags=[\"cube\", \"example\"]\n",
154+
" tags=[\"cube\", \"example\"],\n",
155+
" material_data={\n",
156+
" \"cube_material\": {\n",
157+
" \"diffuse\": np.array([1.0, 0.5, 0.31], dtype=np.float32),\n",
158+
" \"specular\": np.array([0.5, 0.5, 0.5], dtype=np.float32),\n",
159+
" \"shininess\": np.array([32.0], dtype=np.float32)\n",
160+
" }\n",
161+
" },\n",
162+
" material_colors={\n",
163+
" \"cube_material\": \"#FF7F50\"\n",
164+
" }\n",
142165
")\n",
143166
"\n",
144167
"print(f\"Mesh created with {mesh.vertex_count} vertices and {mesh.index_count} indices\")\n",
@@ -213,8 +236,8 @@
213236
"output_type": "stream",
214237
"text": [
215238
"Encoded mesh: 65 bytes for vertices, 41 bytes for indices\n",
216-
"Encoded arrays: ['texture_coords', 'normals']\n",
217-
"Saved mesh to textured_cube.zip, file size: 1543 bytes\n"
239+
"Encoded arrays: ['normals', 'material_data.cube_material.specular', 'texture_coords', 'material_data.cube_material.diffuse', 'material_data.cube_material.shininess', 'index_sizes']\n",
240+
"Saved mesh to textured_cube.zip, file size: 3447 bytes\n"
218241
]
219242
}
220243
],
@@ -248,36 +271,29 @@
248271
"name": "stdout",
249272
"output_type": "stream",
250273
"text": [
251-
"[0 1 2 2 3 0 1 5 6 6 2 1 5 4 7 7 6 5 4 0 3 3 7 4 3 2 6 6 7 3 4 5 1 1 0 4]\n",
252274
"Loaded mesh: 8 vertices, 36 indices\n",
253275
"Material name: cube_material\n",
254276
"Tags: ['cube', 'example']\n",
255277
"\n",
256278
"Texture coordinates shape: (8, 2)\n",
257-
"Normals shape: (8, 3)\n"
279+
"Normals shape: (8, 3)\n",
280+
"Material data: {'cube_material': {'specular': array([0.5, 0.5, 0.5], dtype=float32), 'diffuse': array([1. , 0.5 , 0.31], dtype=float32), 'shininess': array([32.], dtype=float32)}}\n",
281+
"Material colors: {'cube_material': '#FF7F50'}\n"
258282
]
259283
}
260284
],
261285
"source": [
262286
"# Load the mesh from the zip file\n",
263287
"loaded_mesh = MeshUtils.load_from_zip(TexturedMesh, zip_path)\n",
264-
"print(loaded_mesh.indices)\n",
265288
"print(f\"Loaded mesh: {loaded_mesh.vertex_count} vertices, {loaded_mesh.index_count} indices\")\n",
266289
"print(f\"Material name: {loaded_mesh.material_name}\")\n",
267290
"print(f\"Tags: {loaded_mesh.tags}\")\n",
268291
"\n",
269292
"# Verify that the texture coordinates and normals were loaded correctly\n",
270293
"print(f\"\\nTexture coordinates shape: {loaded_mesh.texture_coords.shape}\")\n",
271294
"print(f\"Normals shape: {loaded_mesh.normals.shape}\")\n",
272-
"\n",
273-
"\n",
274-
"\n",
275-
"# Python (Main)\n",
276-
"# 209 0 4 4 0 4 10 4 2 16 0 14 12 8 10 2 8 2 12 2 8 18 0 20 2 6 16 10 8 6 12 6 8 14 16 6 4 0 0 0 0\n",
277-
"\n",
278-
"# JSZip\n",
279-
"# 209 0 4 4 0 4 10 4 16 4 0 14 2 16 2 12 0 2 2 2 14 12 0 16 10 2 2 16 0 4 14 4 4 14 0 2 16 0 0 0 0\n",
280-
"\n"
295+
"print(f\"Material data: {loaded_mesh.material_data}\")\n",
296+
"print(f\"Material colors: {loaded_mesh.material_colors}\")\n"
281297
]
282298
},
283299
{
@@ -431,7 +447,7 @@
431447
"name": "python",
432448
"nbconvert_exporter": "python",
433449
"pygments_lexer": "ipython3",
434-
"version": "3.12.8"
450+
"version": "3.12.11"
435451
}
436452
},
437453
"nbformat": 4,

0 commit comments

Comments
 (0)