working basic loading glbs demo after lots of fixes

This commit is contained in:
Yeicor
2024-02-17 21:04:37 +01:00
parent c357c88a6f
commit 16b3a8ea64
11 changed files with 569 additions and 73 deletions

View File

@@ -13,6 +13,7 @@ from typing import Optional, Dict, Union, AsyncGenerator, List
import tqdm.asyncio
from OCP.TopoDS import TopoDS_Shape
from aiohttp import web
from build123d import Shape, Axis
from dataclasses_json import dataclass_json, config
from tqdm.contrib.logging import logging_redirect_tqdm
@@ -175,6 +176,7 @@ class Server:
def show_cad(self, obj: Union[TopoDS_Shape, any], name: Optional[str] = None, **kwargs):
"""Publishes a CAD object to the server"""
start = time.time()
# Try to grab a shape if a different type of object was passed
if not isinstance(obj, TopoDS_Shape):
# Build123D
@@ -190,6 +192,9 @@ class Server:
if not isinstance(obj, TopoDS_Shape):
raise ValueError(f'Cannot show object of type {type(obj)} (submit issue?)')
# Convert Z-up (OCC convention) to Y-up (GLTF convention)
obj = Shape(obj).rotate(Axis.X, -90).wrapped
self._show_common(name, _hashcode(obj), start, obj)
async def _api_object(self, request: web.Request) -> web.StreamResponse: