Compare commits

...

10 Commits

Author SHA1 Message Date
Yeicor
2370fd72ed Automatically update version to 0.6.15 2024-03-14 16:27:55 +00:00
Yeicor
aef047a658 Merge remote-tracking branch 'origin/master' 2024-03-14 17:27:02 +01:00
Yeicor
d5cdd094e8 reduce idle cpu usage and add todo 2024-03-14 17:26:54 +01:00
Yeicor
9c71573934 Automatically update version to 0.6.14 2024-03-10 18:47:07 +00:00
Yeicor
8fc5ed7544 fix for export_all 2024-03-10 19:46:20 +01:00
Yeicor
1fd932dbc6 Merge remote-tracking branch 'origin/master' 2024-03-10 19:06:59 +01:00
Yeicor
539ac40e3d update readme links 2024-03-10 19:06:51 +01:00
Yeicor
9c2656d7db Automatically update version to 0.6.13 2024-03-10 17:57:32 +00:00
Yeicor
161d76ee69 Merge remote-tracking branch 'origin/master' 2024-03-10 18:56:52 +01:00
Yeicor
431c41a615 fix CI deployment 12 2024-03-10 18:56:45 +01:00
9 changed files with 27 additions and 18 deletions

View File

@@ -19,6 +19,8 @@ jobs:
runs-on: "ubuntu-latest" runs-on: "ubuntu-latest"
steps: steps:
- uses: "actions/checkout@v4" - uses: "actions/checkout@v4"
with:
ref: "${{ inputs.ref }}"
- uses: "actions/setup-node@v4" - uses: "actions/setup-node@v4"
with: with:
cache: "yarn" cache: "yarn"
@@ -35,6 +37,8 @@ jobs:
runs-on: "ubuntu-latest" runs-on: "ubuntu-latest"
steps: steps:
- uses: "actions/checkout@v4" - uses: "actions/checkout@v4"
with:
ref: "${{ inputs.ref }}"
- run: "pipx install poetry" - run: "pipx install poetry"
- uses: "actions/setup-python@v5" - uses: "actions/setup-python@v5"
with: with:
@@ -48,6 +52,8 @@ jobs:
runs-on: "ubuntu-latest" runs-on: "ubuntu-latest"
steps: steps:
- uses: "actions/checkout@v4" - uses: "actions/checkout@v4"
with:
ref: "${{ inputs.ref }}"
- run: "pipx install poetry" - run: "pipx install poetry"
- uses: "actions/setup-python@v5" - uses: "actions/setup-python@v5"
with: with:
@@ -66,13 +72,15 @@ jobs:
runs-on: "ubuntu-latest" runs-on: "ubuntu-latest"
steps: steps:
- uses: "actions/checkout@v4" - uses: "actions/checkout@v4"
with:
ref: "${{ inputs.ref }}"
- run: "pipx install poetry" - run: "pipx install poetry"
- uses: "actions/setup-python@v5" - uses: "actions/setup-python@v5"
with: with:
python-version: "3.11" python-version: "3.11"
cache: "poetry" cache: "poetry"
- run: "SKIP_BUILD_FRONTEND=true poetry install" - run: "SKIP_BUILD_FRONTEND=true poetry install"
- run: "PYTHONPATH=yacv_server YACV_DISABLE_SERVER=true poetry run python example/object.py" - run: "YACV_DISABLE_SERVER=true poetry run python example/object.py"
- uses: "actions/upload-artifact@v4" - uses: "actions/upload-artifact@v4"
with: with:
name: "example" name: "example"

View File

@@ -10,19 +10,19 @@ in a web browser.
- All [GLTF 2.0](https://www.khronos.org/gltf/) features (textures, PBR materials, animations...). - All [GLTF 2.0](https://www.khronos.org/gltf/) features (textures, PBR materials, animations...).
- All [model-viewer](https://modelviewer.dev/) features (smooth controls, augmented reality...). - All [model-viewer](https://modelviewer.dev/) features (smooth controls, augmented reality...).
- Load multiple models at once, load external models and even images as quads. - Load multiple models at once, load external models and even images as quads.
- View and interact with topological entities: faces, edges, vertices and locations.
- Control clipping planes and transparency of each model. - Control clipping planes and transparency of each model.
- View and interact with topological entities: faces, edges, vertices and locations.
- Select any entity and measure bounding box size and distances. - Select any entity and measure bounding box size and distances.
- Fully-featured static deployment: just upload the viewer and models to your server.
- Hot reloading while editing the CAD model (using the `yacv-server` package). - Hot reloading while editing the CAD model (using the `yacv-server` package).
- Fully-featured static deployment: just upload the viewer and models to your server.
## Usage ## Usage
The [example](example) is a fully working project that shows how to use the viewer. The [example](example) is a fully working project that shows how to use the viewer.
You can play with the latest You can play with the latest
demo [here](https://yeicor-3d.github.io/yet-another-cad-viewer/?preload=base.glb&preload=fox.glb&preload=img.jpg.glb&preload=location.glb) demo [here](https://yeicor-3d.github.io/yet-another-cad-viewer/?preload=logo.glb&preload=fox.glb&preload=img.jpg.glb&preload=location.glb)
(or (or
[without animation](https://yeicor-3d.github.io/yet-another-cad-viewer/?autoplay=false&preload=base.glb&preload=fox.glb&preload=img.jpg.glb&preload=location.glb)). [without animation](https://yeicor-3d.github.io/yet-another-cad-viewer/?autoplay=false&preload=logo.glb&preload=fox.glb&preload=img.jpg.glb&preload=location.glb)).
![Demo](assets/screenshot.png) ![Demo](assets/screenshot.png)

View File

@@ -3,7 +3,6 @@ import {settings} from "../misc/settings";
import {inject, onMounted, type Ref, ref, watch} from "vue"; import {inject, onMounted, type Ref, ref, watch} from "vue";
import {VList, VListItem} from "vuetify/lib/components/index.mjs"; import {VList, VListItem} from "vuetify/lib/components/index.mjs";
import {$renderer, $scene} from "@google/model-viewer/lib/model-viewer-base"; import {$renderer, $scene} from "@google/model-viewer/lib/model-viewer-base";
import Loading from "../misc/Loading.vue";
import {ModelViewerElement} from '@google/model-viewer'; import {ModelViewerElement} from '@google/model-viewer';
import type {ModelScene} from "@google/model-viewer/lib/three-components/ModelScene"; import type {ModelScene} from "@google/model-viewer/lib/three-components/ModelScene";
import {Hotspot} from "@google/model-viewer/lib/three-components/Hotspot"; import {Hotspot} from "@google/model-viewer/lib/three-components/Hotspot";
@@ -154,7 +153,7 @@ watch(disableTap, (value) => {
<v-list v-for="src in settings.preload" :key="src"> <v-list v-for="src in settings.preload" :key="src">
<v-list-item>{{ src }}</v-list-item> <v-list-item>{{ src }}</v-list-item>
</v-list> </v-list>
<loading></loading> <!-- Too much idle CPU usage: <loading></loading> -->
</div> </div>
</model-viewer> </model-viewer>

View File

@@ -1,6 +1,6 @@
{ {
"name": "yet-another-cad-viewer", "name": "yet-another-cad-viewer",
"version": "0.6.12", "version": "0.6.15",
"description": "", "description": "",
"license": "MIT", "license": "MIT",
"private": true, "private": true,

View File

@@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "yacv-server" name = "yacv-server"
version = "0.6.12" version = "0.6.15"
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"

View File

@@ -1,6 +1,6 @@
import os import os
from cad import image_to_gltf from yacv_server.cad import image_to_gltf
from yacv_server.yacv import YACV from yacv_server.yacv import YACV
yacv = YACV() yacv = YACV()

View File

@@ -26,6 +26,8 @@ class GLTFMgr:
textures=[Texture(source=0, sampler=0)], textures=[Texture(source=0, sampler=0)],
images=[Image(bufferView=0, mimeType=image[1])], images=[Image(bufferView=0, mimeType=image[1])],
) )
# TODO: Reduce the number of draw calls by merging all faces into a single primitive, and using
# color attributes + extension? to differentiate them (same for edges and vertices)
self.gltf.set_binary_blob(image[0]) self.gltf.set_binary_blob(image[0])
def add_face(self, vertices_raw: List[Tuple[float, float, float]], indices_raw: List[Tuple[int, int, int]], def add_face(self, vertices_raw: List[Tuple[float, float, float]], indices_raw: List[Tuple[int, int, int]],

View File

@@ -7,7 +7,7 @@ from http.server import SimpleHTTPRequestHandler
from iterators import TimeoutIterator from iterators import TimeoutIterator
from mylogger import logger from yacv_server.mylogger import logger
# Find the frontend folder (optional, but recommended) # Find the frontend folder (optional, but recommended)
FILE_DIR = os.path.dirname(__file__) FILE_DIR = os.path.dirname(__file__)

View File

@@ -18,8 +18,8 @@ from OCP.TopoDS import TopoDS_Shape
from build123d import Shape, Axis, Location, Vector from build123d import Shape, Axis, Location, Vector
from dataclasses_json import dataclass_json from dataclasses_json import dataclass_json
from myhttp import HTTPHandler
from yacv_server.cad import get_shape, grab_all_cad, CADCoreLike, CADLike from yacv_server.cad import get_shape, grab_all_cad, CADCoreLike, CADLike
from yacv_server.myhttp import HTTPHandler
from yacv_server.mylogger import logger from yacv_server.mylogger import logger
from yacv_server.pubsub import BufferedPubSub from yacv_server.pubsub import BufferedPubSub
from yacv_server.tessellate import _hashcode, tessellate from yacv_server.tessellate import _hashcode, tessellate
@@ -206,13 +206,13 @@ class YACV:
def shown_object_names(self, apply_removes: bool = True) -> List[str]: def shown_object_names(self, apply_removes: bool = True) -> List[str]:
"""Returns the names of all objects that have been shown""" """Returns the names of all objects that have been shown"""
res = [] res = set()
for obj in self.show_events.buffer(): for obj in self.show_events.buffer():
if not obj.is_remove or not apply_removes: if not obj.is_remove or not apply_removes:
res.append(obj.name) res.add(obj.name)
else: else:
res.remove(obj.name) res.discard(obj.name)
return res return list(res)
def _show_events(self, name: str, apply_removes: bool = True) -> List[UpdatesApiFullData]: def _show_events(self, name: str, apply_removes: bool = True) -> List[UpdatesApiFullData]:
"""Returns the show events with the given name""" """Returns the show events with the given name"""
@@ -302,10 +302,10 @@ def _preprocess_cad(obj: CADLike, **kwargs) -> CADCoreLike:
_find_var_name_count = 0 _find_var_name_count = 0
def _find_var_name(obj: any) -> str: def _find_var_name(obj: any, avoid_levels: int = 2) -> str:
"""A hacky way to get a stable name for an object that may change over time""" """A hacky way to get a stable name for an object that may change over time"""
global _find_var_name_count global _find_var_name_count
for frame in inspect.stack(): for frame in inspect.stack()[avoid_levels:]:
for key, value in frame.frame.f_locals.items(): for key, value in frame.frame.f_locals.items():
if value is obj: if value is obj:
return key return key