mirror of
https://github.com/yeicor-3d/yet-another-cad-viewer.git
synced 2025-12-19 14:14:13 +01:00
faster multi-object load, faster updates and better orthographic camera at different scales
This commit is contained in:
@@ -103,9 +103,10 @@ class GLTFMgr:
|
||||
indices_blob = indices.flatten().tobytes()
|
||||
|
||||
# Check that all vertices are referenced by the indices
|
||||
assert indices.max() == len(vertices) - 1, f"{indices.max()} != {len(vertices) - 1}"
|
||||
assert indices.min() == 0
|
||||
assert np.unique(indices.flatten()).size == len(vertices)
|
||||
# This can happen on broken faces like on some fonts
|
||||
# assert indices.max() == len(vertices) - 1, f"{indices.max()} != {len(vertices) - 1}"
|
||||
# assert indices.min() == 0, f"min({indices}) != 0"
|
||||
# assert np.unique(indices.flatten()).size == len(vertices)
|
||||
|
||||
assert len(tex_coord) == 0 or tex_coord.ndim == 2
|
||||
assert len(tex_coord) == 0 or tex_coord.shape[1] == 2
|
||||
|
||||
@@ -126,21 +126,23 @@ class Server:
|
||||
print('Cannot stop server because it is not running')
|
||||
return
|
||||
|
||||
if os.getenv('YACV_STOP_EARLY', '') == '':
|
||||
# Make sure we can hold the lock for more than 100ms (to avoid exiting too early)
|
||||
logger.info('Stopping server (waiting for at least one frontend request first, cancel with CTRL+C)...')
|
||||
try:
|
||||
while not self.at_least_one_client.is_set():
|
||||
time.sleep(0.01)
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
|
||||
logger.info('Stopping server (waiting for no more frontend requests)...')
|
||||
acquired = time.time()
|
||||
while time.time() - acquired < 1.0:
|
||||
if self.frontend_lock.locked():
|
||||
acquired = time.time()
|
||||
graceful_secs_connect = float(os.getenv('YACV_GRACEFUL_SECS_CONNECT', 12.0))
|
||||
graceful_secs_request = float(os.getenv('YACV_GRACEFUL_SECS_REQUEST', 1.0))
|
||||
# Make sure we can hold the lock for more than 100ms (to avoid exiting too early)
|
||||
logger.info('Stopping server (waiting for at least one frontend request first, cancel with CTRL+C)...')
|
||||
start = time.time()
|
||||
try:
|
||||
while not self.at_least_one_client.is_set() and time.time() - start < graceful_secs_connect:
|
||||
time.sleep(0.01)
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
|
||||
logger.info('Stopping server (waiting for no more frontend requests)...')
|
||||
start = time.time()
|
||||
while time.time() - start < graceful_secs_request:
|
||||
if self.frontend_lock.locked():
|
||||
start = time.time()
|
||||
time.sleep(0.01)
|
||||
|
||||
# Stop the server in the background
|
||||
self.loop.call_soon_threadsafe(lambda *a: self.do_shutdown.set())
|
||||
@@ -190,7 +192,6 @@ class Server:
|
||||
self.at_least_one_client.set()
|
||||
async with sse_response(request) as resp:
|
||||
logger.debug('Client connected: %s', request.remote)
|
||||
resp.ping_interval = 0.1 # HACK: forces flushing of the buffer
|
||||
|
||||
# Send buffered events first, while keeping a lock
|
||||
async with self.frontend_lock:
|
||||
@@ -338,12 +339,12 @@ class Server:
|
||||
logger.debug('Building object %s... %s', name, event.obj)
|
||||
_build_object()
|
||||
|
||||
# In either case return the elements of a subscription to the async generator
|
||||
subscription = self.object_events[name].subscribe()
|
||||
try:
|
||||
return await anext(subscription)
|
||||
finally:
|
||||
await subscription.aclose()
|
||||
# In either case return the elements of a subscription to the async generator
|
||||
subscription = self.object_events[name].subscribe()
|
||||
try:
|
||||
return await anext(subscription)
|
||||
finally:
|
||||
await subscription.aclose()
|
||||
|
||||
def export_all(self, folder: str) -> None:
|
||||
"""Export all previously-shown objects to GLB files in the given folder"""
|
||||
|
||||
@@ -13,9 +13,9 @@ from OCP.TopoDS import TopoDS_Face, TopoDS_Edge, TopoDS_Shape, TopoDS_Vertex
|
||||
from build123d import Shape, Vertex, Face, Location
|
||||
from pygltflib import GLTF2
|
||||
|
||||
from yacv_server.mylogger import logger
|
||||
from yacv_server.cad import CADLike
|
||||
from yacv_server.gltf import GLTFMgr
|
||||
from yacv_server.mylogger import logger
|
||||
|
||||
|
||||
def tessellate(
|
||||
|
||||
Reference in New Issue
Block a user