mirror of
https://github.com/yeicor-3d/yet-another-cad-viewer.git
synced 2025-12-20 22:47:04 +01:00
Compare commits
31 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c71573934 | ||
|
|
8fc5ed7544 | ||
|
|
1fd932dbc6 | ||
|
|
539ac40e3d | ||
|
|
9c2656d7db | ||
|
|
161d76ee69 | ||
|
|
431c41a615 | ||
|
|
7144eb39da | ||
|
|
8e1c89ad6d | ||
|
|
7f692c0b52 | ||
|
|
86043132a8 | ||
|
|
23b4d25464 | ||
|
|
22514d8603 | ||
|
|
b440a89b13 | ||
|
|
cbdb5aff5e | ||
|
|
a3a9258a78 | ||
|
|
9f30ac8eb7 | ||
|
|
e11c9dd5c6 | ||
|
|
520b89af4a | ||
|
|
ba9aef2454 | ||
|
|
509b12cd97 | ||
|
|
40b4d51895 | ||
|
|
af68f8b1ff | ||
|
|
9cb6b29c93 | ||
|
|
3174a39ef9 | ||
|
|
78231aff31 | ||
|
|
39f1231f90 | ||
|
|
ed9251faac | ||
|
|
49d0afa616 | ||
|
|
844860ee1a | ||
|
|
c1ae621e6f |
15
.github/workflows/build.yml
vendored
15
.github/workflows/build.yml
vendored
@@ -6,6 +6,11 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- "master"
|
- "master"
|
||||||
workflow_call:
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
ref:
|
||||||
|
type: "string"
|
||||||
|
required: true
|
||||||
|
description: "The ref (branch or tag) to build"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
@@ -14,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"
|
||||||
@@ -30,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:
|
||||||
@@ -43,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:
|
||||||
@@ -61,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"
|
||||||
|
|||||||
59
.github/workflows/deploy1.yml
vendored
Normal file
59
.github/workflows/deploy1.yml
vendored
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "v**"
|
||||||
|
|
||||||
|
permissions: # Same as deploy2.yml
|
||||||
|
contents: "write"
|
||||||
|
pages: "write"
|
||||||
|
id-token: "write"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
update-versions:
|
||||||
|
runs-on: "ubuntu-latest"
|
||||||
|
steps:
|
||||||
|
- uses: "actions/checkout@v4"
|
||||||
|
with: # Ensure we are not in a detached HEAD state
|
||||||
|
ref: "master"
|
||||||
|
# Check that the tag commit is the latest master commit
|
||||||
|
- run: |
|
||||||
|
git fetch --tags
|
||||||
|
tag_commit=$(git rev-parse ${{ github.ref }})
|
||||||
|
master_commit=$(git rev-parse master)
|
||||||
|
if [ "$tag_commit" != "$master_commit" ]; then
|
||||||
|
echo "The tag commit ($tag_commit) is not the latest master commit ($master_commit)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
- run: "echo 'CLEAN_VERSION=${{ github.ref }}' | sed 's,refs/tags/v,,g' >> $GITHUB_ENV"
|
||||||
|
# Write the new version to package.json
|
||||||
|
- uses: "actions/setup-node@v4"
|
||||||
|
- run: "yarn version --new-version $CLEAN_VERSION --no-git-tag-version"
|
||||||
|
# Write the new version to pyproject.toml
|
||||||
|
- run: "pipx install poetry"
|
||||||
|
- uses: "actions/setup-python@v5"
|
||||||
|
with:
|
||||||
|
python-version: "3.11"
|
||||||
|
cache: "poetry"
|
||||||
|
- run: "poetry version $CLEAN_VERSION"
|
||||||
|
# Commit the changes and move the tag!
|
||||||
|
- run: |
|
||||||
|
git config --global user.email "yeicor@users.noreply.github.com"
|
||||||
|
git config --global user.name "Yeicor"
|
||||||
|
if git commit -am "Automatically update version to $CLEAN_VERSION"; then
|
||||||
|
git push
|
||||||
|
# Move the tag to the new commit
|
||||||
|
git tag -f -a "v$CLEAN_VERSION" -m "v$CLEAN_VERSION"
|
||||||
|
git push -f --tags # Force push the tag to GitHub
|
||||||
|
# The tag move will NOT trigger a new workflow
|
||||||
|
else
|
||||||
|
echo "No source change detected on version update (did you repeat a release tag??)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
deploy: # Makes sure all artifacts are updated and use the new version for the next deployment steps
|
||||||
|
needs: "update-versions"
|
||||||
|
uses: "./.github/workflows/deploy2.yml"
|
||||||
|
secrets: "inherit" # Inherit the secrets from the parent workflow
|
||||||
|
with:
|
||||||
|
ref: "master" # Ensure we are cloning the latest version of the repository
|
||||||
@@ -1,7 +1,10 @@
|
|||||||
on:
|
on:
|
||||||
push:
|
workflow_call:
|
||||||
tags:
|
inputs:
|
||||||
- "v**"
|
ref:
|
||||||
|
type: "string"
|
||||||
|
required: true
|
||||||
|
description: "The ref (branch or tag) to build"
|
||||||
|
|
||||||
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
||||||
permissions:
|
permissions:
|
||||||
@@ -17,25 +20,10 @@ concurrency:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
update-versions:
|
|
||||||
runs-on: "ubuntu-latest"
|
|
||||||
steps:
|
|
||||||
- uses: "actions/checkout@v4"
|
|
||||||
- run: "echo 'CLEAN_VERSION=${{ github.ref }}' | sed 's,refs/tags/v,,g' >> $GITHUB_ENV"
|
|
||||||
# Write the new version to package.json
|
|
||||||
- uses: "actions/setup-node@v4"
|
|
||||||
- run: "yarn version --new-version $CLEAN_VERSION"
|
|
||||||
# Write the new version to pyproject.toml
|
|
||||||
- run: "pipx install poetry"
|
|
||||||
- uses: "actions/setup-python@v5"
|
|
||||||
with:
|
|
||||||
python-version: "3.11"
|
|
||||||
cache: "poetry"
|
|
||||||
- run: "poetry version $CLEAN_VERSION"
|
|
||||||
|
|
||||||
rebuild: # Makes sure all artifacts are updated and use the new version
|
rebuild: # Makes sure all artifacts are updated and use the new version
|
||||||
needs: "update-versions"
|
|
||||||
uses: "./.github/workflows/build.yml"
|
uses: "./.github/workflows/build.yml"
|
||||||
|
with:
|
||||||
|
ref: "${{ inputs.ref }}"
|
||||||
|
|
||||||
deploy-frontend:
|
deploy-frontend:
|
||||||
needs: "rebuild"
|
needs: "rebuild"
|
||||||
@@ -44,24 +32,14 @@ jobs:
|
|||||||
name: "github-pages"
|
name: "github-pages"
|
||||||
url: "${{ steps.deployment.outputs.page_url }}"
|
url: "${{ steps.deployment.outputs.page_url }}"
|
||||||
steps:
|
steps:
|
||||||
- uses: "dawidd6/action-download-artifact@v3"
|
- uses: "actions/download-artifact@v4"
|
||||||
with:
|
with: # Downloads all artifacts from the build job
|
||||||
workflow: "build.yml"
|
|
||||||
name: "frontend"
|
|
||||||
path: "./public"
|
path: "./public"
|
||||||
allow_forks: false
|
- run: | # Merge the subdirectories of public into a single directory
|
||||||
- uses: "dawidd6/action-download-artifact@v3"
|
for dir in public/*; do
|
||||||
with:
|
mv "$dir/"* public/
|
||||||
workflow: "build.yml"
|
rmdir "$dir"
|
||||||
name: "logo"
|
done
|
||||||
path: "./public"
|
|
||||||
allow_forks: false
|
|
||||||
- uses: "dawidd6/action-download-artifact@v3"
|
|
||||||
with:
|
|
||||||
workflow: "build.yml"
|
|
||||||
name: "example"
|
|
||||||
path: "./public"
|
|
||||||
allow_forks: false
|
|
||||||
- uses: "actions/configure-pages@v4"
|
- uses: "actions/configure-pages@v4"
|
||||||
- uses: "actions/upload-pages-artifact@v3"
|
- uses: "actions/upload-pages-artifact@v3"
|
||||||
with:
|
with:
|
||||||
@@ -81,7 +59,17 @@ jobs:
|
|||||||
runs-on: "ubuntu-latest"
|
runs-on: "ubuntu-latest"
|
||||||
steps:
|
steps:
|
||||||
- uses: "actions/checkout@v4"
|
- uses: "actions/checkout@v4"
|
||||||
- uses: "JRubics/poetry-publish@v2"
|
with:
|
||||||
|
ref: "${{ inputs.ref }}"
|
||||||
|
- uses: "actions/setup-node@v4"
|
||||||
|
with:
|
||||||
|
cache: "yarn"
|
||||||
|
- run: "pipx install poetry"
|
||||||
|
- uses: "actions/setup-python@v5"
|
||||||
with:
|
with:
|
||||||
python-version: "3.11"
|
python-version: "3.11"
|
||||||
pypi_token: "${{ secrets.PYPI_TOKEN }}"
|
cache: "poetry"
|
||||||
|
- run: "poetry install"
|
||||||
|
- run: "poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}"
|
||||||
|
- run: "poetry publish --build"
|
||||||
|
|
||||||
@@ -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)).
|
||||||
|
|
||||||

|

|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "yet-another-cad-viewer",
|
"name": "yet-another-cad-viewer",
|
||||||
"version": "0.6.0",
|
"version": "0.6.14",
|
||||||
"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.6.0"
|
version = "0.6.14"
|
||||||
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"
|
||||||
|
|||||||
@@ -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()
|
||||||
|
|||||||
@@ -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__)
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user