mirror of
https://github.com/yeicor-3d/yet-another-cad-viewer.git
synced 2025-12-20 14:37:03 +01:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3675d2f447 | ||
|
|
efc7a1d3b6 | ||
|
|
7166f9fe3d |
@@ -80,6 +80,9 @@ export class NetworkManager extends EventTarget {
|
|||||||
controller.abort(); // Notify the server that we are done
|
controller.abort(); // Notify the server that we are done
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// Server is down, wait a little longer before retrying
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 10 * settings.monitorEveryMs));
|
||||||
}
|
}
|
||||||
controller.abort();
|
controller.abort();
|
||||||
} catch (e) { // Ignore errors (retry very soon)
|
} catch (e) { // Ignore errors (retry very soon)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "yet-another-cad-viewer",
|
"name": "yet-another-cad-viewer",
|
||||||
"version": "0.8.0",
|
"version": "0.8.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "yacv-server"
|
name = "yacv-server"
|
||||||
version = "0.8.0"
|
version = "0.8.1"
|
||||||
description = "Yet Another CAD Viewer (server)"
|
description = "Yet Another CAD Viewer (server)"
|
||||||
authors = ["Yeicor <4929005+Yeicor@users.noreply.github.com>"]
|
authors = ["Yeicor <4929005+Yeicor@users.noreply.github.com>"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|||||||
@@ -91,13 +91,6 @@ def image_to_gltf(source: str | bytes, center: any, width: Optional[float] = Non
|
|||||||
if not isinstance(center_loc, TopLoc_Location):
|
if not isinstance(center_loc, TopLoc_Location):
|
||||||
raise ValueError('Center location not valid')
|
raise ValueError('Center location not valid')
|
||||||
plane = Plane(Location(center_loc))
|
plane = Plane(Location(center_loc))
|
||||||
# Convert coordinates system
|
|
||||||
plane.origin = Vector(plane.origin.X, plane.origin.Z, -plane.origin.Y)
|
|
||||||
plane.z_dir = -plane.y_dir
|
|
||||||
plane.y_dir = plane.z_dir
|
|
||||||
|
|
||||||
def vert(v: Vector) -> Tuple[float, float, float]:
|
|
||||||
return v.X, v.Y, v.Z
|
|
||||||
|
|
||||||
# Load the image to a byte buffer
|
# Load the image to a byte buffer
|
||||||
img = Image.open(source)
|
img = Image.open(source)
|
||||||
@@ -121,13 +114,17 @@ def image_to_gltf(source: str | bytes, center: any, width: Optional[float] = Non
|
|||||||
img.save(img_buf, format=format)
|
img.save(img_buf, format=format)
|
||||||
img_buf = img_buf.getvalue()
|
img_buf = img_buf.getvalue()
|
||||||
|
|
||||||
|
# Convert coordinates system as a last step (gltf is Y-up instead of Z-up)
|
||||||
|
def vert(v: Vector) -> Vector:
|
||||||
|
return Vector(v.X, v.Z, -v.Y)
|
||||||
|
|
||||||
# Build the gltf
|
# Build the gltf
|
||||||
mgr = GLTFMgr(image=(img_buf, save_mime))
|
mgr = GLTFMgr(image=(img_buf, save_mime))
|
||||||
mgr.add_face([
|
mgr.add_face([
|
||||||
vert(plane.origin - plane.x_dir * width / 2 - plane.y_dir * height / 2),
|
|
||||||
vert(plane.origin + plane.x_dir * width / 2 - plane.y_dir * height / 2),
|
|
||||||
vert(plane.origin + plane.x_dir * width / 2 + plane.y_dir * height / 2),
|
|
||||||
vert(plane.origin - plane.x_dir * width / 2 + plane.y_dir * height / 2),
|
vert(plane.origin - plane.x_dir * width / 2 + plane.y_dir * height / 2),
|
||||||
|
vert(plane.origin + plane.x_dir * width / 2 + plane.y_dir * height / 2),
|
||||||
|
vert(plane.origin + plane.x_dir * width / 2 - plane.y_dir * height / 2),
|
||||||
|
vert(plane.origin - plane.x_dir * width / 2 - plane.y_dir * height / 2),
|
||||||
], [
|
], [
|
||||||
(0, 2, 1),
|
(0, 2, 1),
|
||||||
(0, 3, 2),
|
(0, 3, 2),
|
||||||
|
|||||||
@@ -19,9 +19,8 @@ def build_logo(text: bool = True) -> Dict[str, Union[Part, Location, str]]:
|
|||||||
Text('Yet Another\nCAD Viewer', 7, font_path='/usr/share/fonts/TTF/OpenSans-Regular.ttf')
|
Text('Yet Another\nCAD Viewer', 7, font_path='/usr/share/fonts/TTF/OpenSans-Regular.ttf')
|
||||||
extrude(amount=1)
|
extrude(amount=1)
|
||||||
|
|
||||||
logo_img_location = logo_obj.faces().group_by(Axis.X)[0].face().center_location # Avoid overlapping:
|
logo_img_location = logo_obj.faces().group_by(Axis.X)[0].face().center_location
|
||||||
logo_img_location.position = Vector(logo_img_location.position.X - 4e-2, logo_img_location.position.Y,
|
logo_img_location *= Location((0, 0, 4e-2), (0, 0, 90)) # Avoid overlapping and adjust placement
|
||||||
logo_img_location.position.Z)
|
|
||||||
|
|
||||||
logo_img_path = os.path.join(ASSETS_DIR, 'img.jpg')
|
logo_img_path = os.path.join(ASSETS_DIR, 'img.jpg')
|
||||||
img_glb_bytes, img_name = image_to_gltf(logo_img_path, logo_img_location, height=18)
|
img_glb_bytes, img_name = image_to_gltf(logo_img_path, logo_img_location, height=18)
|
||||||
|
|||||||
Reference in New Issue
Block a user