Skip to content

Commit b629f07

Browse files
committed
Fix broken gltf exports and minor cleanup
1 parent 9e4f571 commit b629f07

File tree

7 files changed

+39
-33
lines changed

7 files changed

+39
-33
lines changed

assets/licenses.txt

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,7 @@ third-party archives.
981981

982982
The following npm package may be included in this product:
983983

984-
- typescript@5.7.2
984+
- typescript@5.8.3
985985

986986
This package contains the following license:
987987

@@ -1121,7 +1121,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11211121

11221122
The following npm package may be included in this product:
11231123

1124-
- @lit-labs/ssr-dom-shim@1.2.1
1124+
- @lit-labs/ssr-dom-shim@1.3.0
11251125

11261126
This package contains the following license:
11271127

@@ -1247,7 +1247,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12471247

12481248
The following npm package may be included in this product:
12491249

1250-
- @babel/parser@7.26.3
1250+
- @babel/parser@7.27.0
12511251

12521252
This package contains the following license:
12531253

@@ -1420,7 +1420,7 @@ The following npm packages may be included in this product:
14201420

14211421
- @babel/helper-string-parser@7.25.9
14221422
- @babel/helper-validator-identifier@7.25.9
1423-
- @babel/types@7.26.3
1423+
- @babel/types@7.27.0
14241424

14251425
These packages each contain the following license:
14261426

@@ -1451,7 +1451,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14511451

14521452
The following npm package may be included in this product:
14531453

1454-
- three-mesh-bvh@0.8.3
1454+
- three-mesh-bvh@0.9.0
14551455

14561456
This package contains the following license:
14571457

@@ -1601,7 +1601,7 @@ The MIT license applies to all non-font and non-icon files.
16011601

16021602
The following npm package may be included in this product:
16031603

1604-
- semver@7.6.3
1604+
- semver@7.7.1
16051605

16061606
This package contains the following license:
16071607

@@ -1685,13 +1685,13 @@ THE SOFTWARE.
16851685

16861686
The following npm package may be included in this product:
16871687

1688-
- three@0.171.0
1688+
- three@0.175.0
16891689

16901690
This package contains the following license:
16911691

16921692
The MIT License
16931693

1694-
Copyright © 2010-2024 three.js authors
1694+
Copyright © 2010-2025 three.js authors
16951695

16961696
Permission is hereby granted, free of charge, to any person obtaining a copy
16971697
of this software and associated documentation files (the "Software"), to deal
@@ -1775,7 +1775,7 @@ THE SOFTWARE.
17751775

17761776
The following npm package may be included in this product:
17771777

1778-
- vuetify@3.7.6
1778+
- vuetify@3.8.0
17791779

17801780
This package contains the following license:
17811781

@@ -1844,7 +1844,7 @@ THE SOFTWARE.
18441844

18451845
The following npm package may be included in this product:
18461846

1847-
- ktx-parse@0.7.1
1847+
- ktx-parse@1.0.0
18481848

18491849
This package contains the following license:
18501850

@@ -1906,9 +1906,9 @@ SOFTWARE.
19061906

19071907
The following npm packages may be included in this product:
19081908

1909-
- @gltf-transform/core@4.1.1
1910-
- @gltf-transform/extensions@4.1.1
1911-
- @gltf-transform/functions@4.1.1
1909+
- @gltf-transform/core@4.1.3
1910+
- @gltf-transform/extensions@4.1.3
1911+
- @gltf-transform/functions@4.1.3
19121912

19131913
These packages each contain the following license:
19141914

@@ -1968,7 +1968,7 @@ THE SOFTWARE.
19681968

19691969
The following npm package may be included in this product:
19701970

1971-
- postcss@8.4.49
1971+
- postcss@8.5.3
19721972

19731973
This package contains the following license:
19741974

@@ -1997,7 +1997,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19971997

19981998
The following npm package may be included in this product:
19991999

2000-
- nanoid@3.3.8
2000+
- nanoid@3.3.11
20012001

20022002
This package contains the following license:
20032003

yacv_server/cad.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from OCP.TopLoc import TopLoc_Location
1111
from OCP.TopTools import TopTools_IndexedMapOfShape
1212
from OCP.TopoDS import TopoDS_Shape
13-
from build123d import Compound, Shape, Color
13+
from build123d import Compound, Color
1414

1515
from yacv_server.gltf import GLTFMgr
1616

@@ -78,7 +78,7 @@ def get_shape(obj: CADLike, error: bool = True) -> Optional[CADCoreLike]:
7878
# Sorting is required to improve hashcode consistency
7979
shapes_raw_filtered_sorted = sorted(shapes_raw_filtered, key=lambda x: _hashcode(x))
8080
# Build a single compound shape
81-
shapes_bd = [Shape(shape) for shape in shapes_raw_filtered_sorted if shape is not None]
81+
shapes_bd = [Compound(shape) for shape in shapes_raw_filtered_sorted if shape is not None]
8282
return get_shape(Compound(shapes_bd), error)
8383
except TypeError:
8484
pass
@@ -121,11 +121,11 @@ def image_to_gltf(source: str | bytes, center: any, width: Optional[float] = Non
121121
hasher = hashlib.md5()
122122
hasher.update(source)
123123
name = 'image_' + hasher.hexdigest()
124-
format: str
124+
_format: str
125125
if save_mime == 'image/jpeg':
126-
format = 'JPEG'
126+
_format = 'JPEG'
127127
elif save_mime == 'image/png':
128-
format = 'PNG'
128+
_format = 'PNG'
129129
else:
130130
raise ValueError(f'Unsupported save MIME type (for GLTF files): {save_mime}')
131131

@@ -154,7 +154,7 @@ def image_to_gltf(source: str | bytes, center: any, width: Optional[float] = Non
154154
img = img.resize((new_width, new_height))
155155

156156
# Save the image to a buffer
157-
img.save(img_buf, format=format)
157+
img.save(img_buf, format=_format)
158158
img_buf = img_buf.getvalue()
159159

160160
# Convert coordinates system as a last step (gltf is Y-up instead of Z-up)

yacv_server/gltf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ def build(self) -> GLTF2:
169169
self.gltf.images = [Image(bufferView=len(buffers_list), mimeType=self.image[1])]
170170
self.gltf.textures = [Texture(source=0, sampler=0)]
171171
self.gltf.samplers = [Sampler(magFilter=NEAREST)]
172+
# noinspection PyPep8Naming
172173
self.gltf.materials[0].pbrMetallicRoughness.baseColorTexture = TextureInfo(index=0)
173174
buffers_list.append((Accessor(), BufferView(), self.image[0]))
174175

yacv_server/myhttp.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,4 @@ def _api_object(self, obj_name: str):
138138
self.send_header('E-Tag', f'"{_hash}"')
139139
self.end_headers()
140140
self.wfile.write(exported_glb)
141+
return None

yacv_server/pubsub.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import queue
2-
import queue
32
import threading
4-
from typing import List, TypeVar, \
5-
Generic, Generator
3+
from typing import List, TypeVar, Generic, Generator
64

75
from yacv_server.mylogger import logger
86

@@ -58,7 +56,7 @@ def _unsubscribe(self, q: queue.Queue[T]):
5856

5957
def subscribe(self, include_buffered: bool = True, include_future: bool = True, yield_timeout: float = 0.0) -> \
6058
Generator[T, None, None]:
61-
"""Subscribes to events as an generator that yields events and automatically unsubscribes"""
59+
"""Subscribes to events as a generator that yields events and automatically unsubscribes"""
6260
q = self._subscribe(include_buffered, include_future)
6361
try:
6462
while True:

yacv_server/tessellate.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from OCP.GCPnts import GCPnts_TangentialDeflection
66
from OCP.TopLoc import TopLoc_Location
77
from OCP.TopoDS import TopoDS_Face, TopoDS_Edge, TopoDS_Shape, TopoDS_Vertex
8-
from build123d import Shape, Vertex, Face, Location
8+
from build123d import Vertex, Face, Location, Compound
99
from pygltflib import GLTF2
1010

1111
from yacv_server.cad import CADCoreLike, ColorTuple
@@ -33,7 +33,7 @@ def tessellate(
3333
mgr.add_location(Location(cad_like))
3434

3535
elif isinstance(cad_like, TopoDS_Shape):
36-
shape = Shape(cad_like)
36+
shape = Compound(cad_like)
3737

3838
# Perform tessellation tasks
3939
edge_to_faces: Dict[str, List[TopoDS_Face]] = {}
@@ -59,6 +59,9 @@ def tessellate(
5959
for vertex in shape.vertices():
6060
_tessellate_vertex(mgr, vertex.wrapped, vertex_to_faces.get(vertex.wrapped, []), obj_color)
6161

62+
else:
63+
raise TypeError(f"Unsupported type: {type(cad_like)}: {cad_like}")
64+
6265
return mgr.build()
6366

6467

@@ -69,9 +72,10 @@ def _tessellate_face(
6972
angular_tolerance: float = 0.1,
7073
color: Optional[ColorTuple] = None,
7174
):
72-
face = Shape(ocp_face)
75+
face = Compound(ocp_face)
7376
# face.mesh(tolerance, angular_tolerance)
7477
tri_mesh = face.tessellate(tolerance, angular_tolerance)
78+
# noinspection PyArgumentList
7579
poly = BRep_Tool.Triangulation_s(face.wrapped, TopLoc_Location())
7680
if poly is None:
7781
logger.warn("No triangulation found for face")
@@ -86,6 +90,7 @@ def _tessellate_face(
8690
vertices = tri_mesh[0]
8791
indices = tri_mesh[1]
8892
mgr.add_face(vertices, indices, uv, color)
93+
return None
8994

9095

9196
def _push_point(v: Tuple[float, float, float], faces: List[TopoDS_Face]) -> Tuple[float, float, float]:

yacv_server/yacv.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@
99
import time
1010
from dataclasses import dataclass
1111
from http.server import ThreadingHTTPServer
12+
from io import BytesIO
1213
from threading import Thread
1314
from typing import Optional, Dict, Union, Callable, List, Tuple
1415

1516
from OCP.TopLoc import TopLoc_Location
1617
from OCP.TopoDS import TopoDS_Shape
18+
from PIL import Image
1719
# noinspection PyProtectedMember
18-
from build123d import Shape, Axis, Location, Vector, Color
20+
from build123d import Shape, Axis, Location, Vector
1921
from dataclasses_json import dataclass_json
20-
from PIL import Image
21-
from io import BytesIO
2222

23-
from yacv_server.cad import _hashcode, ColorTuple, get_color
23+
from yacv_server.cad import _hashcode, get_color
2424
from yacv_server.cad import get_shape, grab_all_cad, CADCoreLike, CADLike
2525
from yacv_server.gltf import get_version
2626
from yacv_server.myhttp import HTTPHandler
@@ -95,7 +95,7 @@ class YACV:
9595
"""Default texture to use for model faces, in (data, mimetype) format.
9696
If left as None, a default checkerboard texture will be used.
9797
98-
It can be set with the YACV_BASE_TEXTURE=<uri> and overriden by `show(..., texture="<uri>")`.
98+
It can be set with the YACV_BASE_TEXTURE=<uri> and overridden by `show(..., texture="<uri>")`.
9999
The <uri> can be file:<path> or data:<mime>;base64,<data> where <mime> is the mime type and
100100
<data> is the base64 encoded image."""
101101

@@ -331,6 +331,7 @@ def export(self, name: str) -> Optional[Tuple[bytes, str]]:
331331
try:
332332
return next(subscription), event.hash
333333
finally:
334+
# noinspection PyInconsistentReturns
334335
subscription.close()
335336

336337
def export_all(self, folder: str,

0 commit comments

Comments
 (0)