Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -27,7 +27,7 @@ from OCC.Core.StlAPI import StlAPI_Writer
|
|
| 27 |
os.environ['PYVISTA_OFF_SCREEN'] = 'true'
|
| 28 |
os.environ['VTK_GRAPHICS_BACKEND'] = 'OSMesa'
|
| 29 |
|
| 30 |
-
st.set_page_config(page_title="CastingSim
|
| 31 |
|
| 32 |
st.markdown("""
|
| 33 |
<style>
|
|
@@ -82,7 +82,7 @@ def compilar_pdf():
|
|
| 82 |
pdf = FPDF()
|
| 83 |
pdf.add_page()
|
| 84 |
pdf.set_font("Arial", 'B', 16)
|
| 85 |
-
pdf.cell(0, 10, "LAUDO DE ENGENHARIA - CASTINGSIM
|
| 86 |
pdf.ln(5)
|
| 87 |
|
| 88 |
pdf.set_font("Arial", 'B', 12)
|
|
@@ -206,7 +206,7 @@ if st.session_state.step in [1, 2, 3, 4, 4.5, 5]:
|
|
| 206 |
st.caption("**ETAPA EXTRA: RENDERIZAÇÃO DE VÍDEO**")
|
| 207 |
|
| 208 |
if st.session_state.step not in [3.5, 4.5]:
|
| 209 |
-
st.title("🛡️ CastingSim
|
| 210 |
st.markdown("---")
|
| 211 |
|
| 212 |
# ==========================================
|
|
@@ -288,7 +288,8 @@ elif st.session_state.step == 3:
|
|
| 288 |
ry = st.slider("Eixo Y", 0, 360, value=int(st.session_state.rot_y))
|
| 289 |
rz = st.slider("Eixo Z", 0, 360, value=int(st.session_state.rot_z))
|
| 290 |
|
| 291 |
-
st.write("**
|
|
|
|
| 292 |
ox = st.number_input("Eixo X", value=float(st.session_state.off_x), step=1.0)
|
| 293 |
oy = st.number_input("Eixo Y", value=float(st.session_state.off_y), step=1.0)
|
| 294 |
oz = st.number_input("Eixo Z", value=float(st.session_state.off_z), step=1.0)
|
|
@@ -319,7 +320,7 @@ elif st.session_state.step == 3:
|
|
| 319 |
<model-viewer src="data:model/gltf-binary;base64,{st.session_state.b64_proxy}"
|
| 320 |
orientation="{st.session_state.rot_x}deg {st.session_state.rot_y}deg {st.session_state.rot_z}deg"
|
| 321 |
style="width: 100%; height: 480px; background-color: #f4f6f9;" camera-controls>
|
| 322 |
-
<button slot="hotspot-1" data-position="{p_m[0]} {p_m[1]} {p_m[2]}" style="background-color: red; width: 16px; height: 16px; border-radius: 50%; border: 2px solid white;"></button>
|
| 323 |
</model-viewer>
|
| 324 |
"""
|
| 325 |
components.html(html, height=500)
|
|
@@ -335,7 +336,7 @@ elif st.session_state.step == 3:
|
|
| 335 |
st.rerun()
|
| 336 |
|
| 337 |
# ==========================================
|
| 338 |
-
# ETAPA 3.5: O NÚCLEO FÍSICO
|
| 339 |
# ==========================================
|
| 340 |
elif st.session_state.step == 3.5:
|
| 341 |
st.title("⏳ Processando Solver FEM...")
|
|
@@ -343,12 +344,16 @@ elif st.session_state.step == 3.5:
|
|
| 343 |
progress_bar = st.progress(0, text="Iniciando Motores de Cálculo Termodinâmico...")
|
| 344 |
|
| 345 |
try:
|
| 346 |
-
progress_bar.progress(10, text="[10%] Lendo geometria base e
|
| 347 |
mesh_leve = pv.read(st.session_state.path_stl)
|
| 348 |
mesh_leve.rotate_x(st.session_state.rot_x, inplace=True)
|
| 349 |
mesh_leve.rotate_y(st.session_state.rot_y, inplace=True)
|
| 350 |
mesh_leve.rotate_z(st.session_state.rot_z, inplace=True)
|
| 351 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 352 |
|
| 353 |
progress_bar.progress(30, text="[30%] INICIANDO SUBDIVISÃO ISOTRÓPICA (Refinando malha para a Termodinâmica)...")
|
| 354 |
time.sleep(0.5)
|
|
@@ -357,7 +362,7 @@ elif st.session_state.step == 3.5:
|
|
| 357 |
if st.session_state.sub_div > 0:
|
| 358 |
mesh_pesada = mesh_pesada.subdivide(st.session_state.sub_div, subfilter='linear')
|
| 359 |
|
| 360 |
-
progress_bar.progress(45, text="[45%] Integrando Cinemática Heurística ao Solver Térmico (Física
|
| 361 |
|
| 362 |
pts = mesh_pesada.points
|
| 363 |
|
|
@@ -365,8 +370,9 @@ elif st.session_state.step == 3.5:
|
|
| 365 |
y_min, y_max = np.min(y_coords), np.max(y_coords)
|
| 366 |
y_norm = (y_coords - y_min) / (y_max - y_min + 1e-6)
|
| 367 |
|
| 368 |
-
|
| 369 |
-
|
|
|
|
| 370 |
r_norm = r_coords / (np.max(r_coords) + 1e-6)
|
| 371 |
|
| 372 |
turbulencia = np.random.normal(0, 0.08, size=mesh_pesada.n_points)
|
|
@@ -377,7 +383,7 @@ elif st.session_state.step == 3.5:
|
|
| 377 |
calor_dinamico = (campo_fluido - c_min) / (c_max - c_min + 1e-6)
|
| 378 |
|
| 379 |
progress_bar.progress(60, text="[60%] Calculando Massa Térmica e Curvatura...")
|
| 380 |
-
dist_ao_massalote = np.linalg.norm(pts -
|
| 381 |
max_fluxo = np.max(dist_ao_massalote)
|
| 382 |
isolamento = (dist_ao_massalote / (max_fluxo + 1e-6))
|
| 383 |
|
|
@@ -454,6 +460,9 @@ elif st.session_state.step == 3.5:
|
|
| 454 |
st.session_state.relatorio_ia = gerar_diagnostico_ia(mod_cm, t_sol_segundos_totais, st.session_state.t_vaz, st.session_state.t_molde, max_risco_calculado, num_reynolds, st.session_state.vel_vaz)
|
| 455 |
st.session_state.relatorio_pdf = compilar_pdf()
|
| 456 |
|
|
|
|
|
|
|
|
|
|
| 457 |
progress_bar.progress(100, text="[100%] Cálculos finalizados! Saltando para Resultados...")
|
| 458 |
time.sleep(0.5)
|
| 459 |
st.session_state.step = 4
|
|
@@ -490,13 +499,18 @@ elif st.session_state.step == 4:
|
|
| 490 |
st.rerun()
|
| 491 |
|
| 492 |
col_v1, col_v2, col_v3 = st.columns(3)
|
| 493 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 494 |
|
| 495 |
with col_v1:
|
| 496 |
st.write("🔥 **Mapa Térmico Base (Física Unificada)**")
|
| 497 |
html_termico = f"""<script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/3.4.0/model-viewer.min.js"></script>
|
| 498 |
<model-viewer src="data:model/gltf-binary;base64,{st.session_state.b64_termico}" style="width: 100%; height: 350px; background-color: #1e1e1e;" camera-controls shadow-intensity="1">
|
| 499 |
-
<button slot="hotspot-1" data-position="{p_m[0]} {p_m[1]} {p_m[2]}" style="background-color:
|
| 500 |
</model-viewer>"""
|
| 501 |
components.html(html_termico, height=400)
|
| 502 |
|
|
@@ -514,7 +528,7 @@ elif st.session_state.step == 4:
|
|
| 514 |
st.download_button(
|
| 515 |
label="📄 Baixar Laudo (.PDF)",
|
| 516 |
data=st.session_state.relatorio_pdf,
|
| 517 |
-
file_name="
|
| 518 |
mime="application/pdf",
|
| 519 |
type="primary",
|
| 520 |
use_container_width=True
|
|
@@ -530,7 +544,7 @@ elif st.session_state.step == 4:
|
|
| 530 |
# ==========================================
|
| 531 |
elif st.session_state.step == 4.5:
|
| 532 |
st.title("🎬 Preparando a Linha do Tempo (Scrubber)...")
|
| 533 |
-
st.info("Gerando os instantes chave
|
| 534 |
prog_video = st.progress(0, text="Iniciando motor de extração...")
|
| 535 |
|
| 536 |
try:
|
|
@@ -548,14 +562,15 @@ elif st.session_state.step == 4.5:
|
|
| 548 |
pass
|
| 549 |
mesh_molde_wire.points /= 1000.0
|
| 550 |
|
| 551 |
-
prog_video.progress(20, text="[20%] Aplicando campo heurístico
|
| 552 |
pts = mesh_video.points
|
| 553 |
y_coords = pts[:, 1]
|
| 554 |
y_min, y_max = np.min(y_coords), np.max(y_coords)
|
| 555 |
y_norm = (y_coords - y_min) / (y_max - y_min + 1e-6)
|
| 556 |
|
| 557 |
-
|
| 558 |
-
|
|
|
|
| 559 |
r_norm = r_coords / (np.max(r_coords) + 1e-6)
|
| 560 |
|
| 561 |
turbulencia = np.random.normal(0, 0.08, size=mesh_video.n_points)
|
|
@@ -568,7 +583,6 @@ elif st.session_state.step == 4.5:
|
|
| 568 |
st.session_state.frames_paths = []
|
| 569 |
temp_dir = tempfile.mkdtemp()
|
| 570 |
|
| 571 |
-
# 10 frames bastam para um slider manual excelente
|
| 572 |
passos = 10
|
| 573 |
|
| 574 |
for i in range(1, passos + 1):
|
|
@@ -615,42 +629,65 @@ elif st.session_state.step == 4.5:
|
|
| 615 |
st.rerun()
|
| 616 |
|
| 617 |
# ==========================================
|
| 618 |
-
# ETAPA 5: O CINEMA (
|
| 619 |
# ==========================================
|
| 620 |
elif st.session_state.step == 5:
|
| 621 |
-
st.header("5. Telemetria Cinemática (
|
| 622 |
-
st.write(f"Velocidade de Vazamento: **{st.session_state.vel_vaz} m/s** |
|
| 623 |
|
| 624 |
if len(st.session_state.frames_paths) > 0:
|
| 625 |
-
|
| 626 |
-
|
| 627 |
-
|
| 628 |
-
|
| 629 |
-
|
| 630 |
-
|
| 631 |
-
|
| 632 |
-
|
| 633 |
-
with open(caminho_frame, "rb") as f:
|
| 634 |
-
b64_frame = base64.b64encode(f.read()).decode()
|
| 635 |
|
| 636 |
-
|
| 637 |
-
|
| 638 |
-
|
| 639 |
-
|
| 640 |
-
|
| 641 |
-
|
| 642 |
-
|
| 643 |
-
|
| 644 |
-
<
|
| 645 |
-
|
| 646 |
-
|
| 647 |
-
|
| 648 |
-
|
| 649 |
-
|
| 650 |
-
|
| 651 |
-
|
| 652 |
-
|
| 653 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 654 |
else:
|
| 655 |
st.warning("Motor WebGL não encontrou frames no Disco Rígido.")
|
| 656 |
|
|
|
|
| 27 |
os.environ['PYVISTA_OFF_SCREEN'] = 'true'
|
| 28 |
os.environ['VTK_GRAPHICS_BACKEND'] = 'OSMesa'
|
| 29 |
|
| 30 |
+
st.set_page_config(page_title="CastingSim V37", layout="wide")
|
| 31 |
|
| 32 |
st.markdown("""
|
| 33 |
<style>
|
|
|
|
| 82 |
pdf = FPDF()
|
| 83 |
pdf.add_page()
|
| 84 |
pdf.set_font("Arial", 'B', 16)
|
| 85 |
+
pdf.cell(0, 10, "LAUDO DE ENGENHARIA - CASTINGSIM V37", 0, 1, 'C')
|
| 86 |
pdf.ln(5)
|
| 87 |
|
| 88 |
pdf.set_font("Arial", 'B', 12)
|
|
|
|
| 206 |
st.caption("**ETAPA EXTRA: RENDERIZAÇÃO DE VÍDEO**")
|
| 207 |
|
| 208 |
if st.session_state.step not in [3.5, 4.5]:
|
| 209 |
+
st.title("🛡️ CastingSim V37: Snap Magnético e Câmbio Dupla Embreagem")
|
| 210 |
st.markdown("---")
|
| 211 |
|
| 212 |
# ==========================================
|
|
|
|
| 288 |
ry = st.slider("Eixo Y", 0, 360, value=int(st.session_state.rot_y))
|
| 289 |
rz = st.slider("Eixo Z", 0, 360, value=int(st.session_state.rot_z))
|
| 290 |
|
| 291 |
+
st.write("**Localizador de Massalote (Aproximado)**")
|
| 292 |
+
st.caption("O algoritmo 'Snap' corrigirá a posição para a face real mais próxima.")
|
| 293 |
ox = st.number_input("Eixo X", value=float(st.session_state.off_x), step=1.0)
|
| 294 |
oy = st.number_input("Eixo Y", value=float(st.session_state.off_y), step=1.0)
|
| 295 |
oz = st.number_input("Eixo Z", value=float(st.session_state.off_z), step=1.0)
|
|
|
|
| 320 |
<model-viewer src="data:model/gltf-binary;base64,{st.session_state.b64_proxy}"
|
| 321 |
orientation="{st.session_state.rot_x}deg {st.session_state.rot_y}deg {st.session_state.rot_z}deg"
|
| 322 |
style="width: 100%; height: 480px; background-color: #f4f6f9;" camera-controls>
|
| 323 |
+
<button slot="hotspot-1" data-position="{p_m[0]} {p_m[1]} {p_m[2]}" style="background-color: red; width: 16px; height: 16px; border-radius: 50%; border: 2px solid white; box-shadow: 0 0 10px red;"></button>
|
| 324 |
</model-viewer>
|
| 325 |
"""
|
| 326 |
components.html(html, height=500)
|
|
|
|
| 336 |
st.rerun()
|
| 337 |
|
| 338 |
# ==========================================
|
| 339 |
+
# ETAPA 3.5: O NÚCLEO FÍSICO COM LOCALIZADOR MAGNÉTICO
|
| 340 |
# ==========================================
|
| 341 |
elif st.session_state.step == 3.5:
|
| 342 |
st.title("⏳ Processando Solver FEM...")
|
|
|
|
| 344 |
progress_bar = st.progress(0, text="Iniciando Motores de Cálculo Termodinâmico...")
|
| 345 |
|
| 346 |
try:
|
| 347 |
+
progress_bar.progress(10, text="[10%] Lendo geometria base e ativando Localizador Magnético...")
|
| 348 |
mesh_leve = pv.read(st.session_state.path_stl)
|
| 349 |
mesh_leve.rotate_x(st.session_state.rot_x, inplace=True)
|
| 350 |
mesh_leve.rotate_y(st.session_state.rot_y, inplace=True)
|
| 351 |
mesh_leve.rotate_z(st.session_state.rot_z, inplace=True)
|
| 352 |
+
|
| 353 |
+
# A MÁGICA DO SNAPPING V37: Achando a coordenada real exata
|
| 354 |
+
p_riser_aprox = np.array([st.session_state.off_x, st.session_state.off_y, st.session_state.off_z])
|
| 355 |
+
closest_idx = mesh_leve.find_closest_point(p_riser_aprox)
|
| 356 |
+
p_riser_real = mesh_leve.points[closest_idx] # O verdadeiro ponto de início!
|
| 357 |
|
| 358 |
progress_bar.progress(30, text="[30%] INICIANDO SUBDIVISÃO ISOTRÓPICA (Refinando malha para a Termodinâmica)...")
|
| 359 |
time.sleep(0.5)
|
|
|
|
| 362 |
if st.session_state.sub_div > 0:
|
| 363 |
mesh_pesada = mesh_pesada.subdivide(st.session_state.sub_div, subfilter='linear')
|
| 364 |
|
| 365 |
+
progress_bar.progress(45, text="[45%] Integrando Cinemática Heurística ao Solver Térmico (Física V37)...")
|
| 366 |
|
| 367 |
pts = mesh_pesada.points
|
| 368 |
|
|
|
|
| 370 |
y_min, y_max = np.min(y_coords), np.max(y_coords)
|
| 371 |
y_norm = (y_coords - y_min) / (y_max - y_min + 1e-6)
|
| 372 |
|
| 373 |
+
# O PULO DO GATO: A distância radial agora nasce do Ponto Real Snapado!
|
| 374 |
+
px, py, pz = p_riser_real
|
| 375 |
+
r_coords = np.sqrt((pts[:, 0] - px)**2 + (pts[:, 2] - pz)**2)
|
| 376 |
r_norm = r_coords / (np.max(r_coords) + 1e-6)
|
| 377 |
|
| 378 |
turbulencia = np.random.normal(0, 0.08, size=mesh_pesada.n_points)
|
|
|
|
| 383 |
calor_dinamico = (campo_fluido - c_min) / (c_max - c_min + 1e-6)
|
| 384 |
|
| 385 |
progress_bar.progress(60, text="[60%] Calculando Massa Térmica e Curvatura...")
|
| 386 |
+
dist_ao_massalote = np.linalg.norm(pts - p_riser_real, axis=1)
|
| 387 |
max_fluxo = np.max(dist_ao_massalote)
|
| 388 |
isolamento = (dist_ao_massalote / (max_fluxo + 1e-6))
|
| 389 |
|
|
|
|
| 460 |
st.session_state.relatorio_ia = gerar_diagnostico_ia(mod_cm, t_sol_segundos_totais, st.session_state.t_vaz, st.session_state.t_molde, max_risco_calculado, num_reynolds, st.session_state.vel_vaz)
|
| 461 |
st.session_state.relatorio_pdf = compilar_pdf()
|
| 462 |
|
| 463 |
+
# Guardando o ponto real na sessão para a etapa de vídeo
|
| 464 |
+
st.session_state.p_riser_real = p_riser_real.tolist()
|
| 465 |
+
|
| 466 |
progress_bar.progress(100, text="[100%] Cálculos finalizados! Saltando para Resultados...")
|
| 467 |
time.sleep(0.5)
|
| 468 |
st.session_state.step = 4
|
|
|
|
| 499 |
st.rerun()
|
| 500 |
|
| 501 |
col_v1, col_v2, col_v3 = st.columns(3)
|
| 502 |
+
|
| 503 |
+
# O Ponto vermelho agora mostra a posição REAL snapada
|
| 504 |
+
if 'p_riser_real' in st.session_state:
|
| 505 |
+
p_m = [st.session_state.p_riser_real[0]/1000.0, st.session_state.p_riser_real[1]/1000.0, st.session_state.p_riser_real[2]/1000.0]
|
| 506 |
+
else:
|
| 507 |
+
p_m = [st.session_state.off_x/1000.0, st.session_state.off_y/1000.0, st.session_state.off_z/1000.0]
|
| 508 |
|
| 509 |
with col_v1:
|
| 510 |
st.write("🔥 **Mapa Térmico Base (Física Unificada)**")
|
| 511 |
html_termico = f"""<script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/3.4.0/model-viewer.min.js"></script>
|
| 512 |
<model-viewer src="data:model/gltf-binary;base64,{st.session_state.b64_termico}" style="width: 100%; height: 350px; background-color: #1e1e1e;" camera-controls shadow-intensity="1">
|
| 513 |
+
<button slot="hotspot-1" data-position="{p_m[0]} {p_m[1]} {p_m[2]}" style="background-color: lime; width: 14px; height: 14px; border-radius: 50%; border: 2px solid white;"></button>
|
| 514 |
</model-viewer>"""
|
| 515 |
components.html(html_termico, height=400)
|
| 516 |
|
|
|
|
| 528 |
st.download_button(
|
| 529 |
label="📄 Baixar Laudo (.PDF)",
|
| 530 |
data=st.session_state.relatorio_pdf,
|
| 531 |
+
file_name="Laudo_CastingSim_V37.pdf",
|
| 532 |
mime="application/pdf",
|
| 533 |
type="primary",
|
| 534 |
use_container_width=True
|
|
|
|
| 544 |
# ==========================================
|
| 545 |
elif st.session_state.step == 4.5:
|
| 546 |
st.title("🎬 Preparando a Linha do Tempo (Scrubber)...")
|
| 547 |
+
st.info("Gerando os instantes chave. O fluido agora orbita o ponto real exato (Localizador Magnético ativado).")
|
| 548 |
prog_video = st.progress(0, text="Iniciando motor de extração...")
|
| 549 |
|
| 550 |
try:
|
|
|
|
| 562 |
pass
|
| 563 |
mesh_molde_wire.points /= 1000.0
|
| 564 |
|
| 565 |
+
prog_video.progress(20, text="[20%] Aplicando campo heurístico centrado no Massalote...")
|
| 566 |
pts = mesh_video.points
|
| 567 |
y_coords = pts[:, 1]
|
| 568 |
y_min, y_max = np.min(y_coords), np.max(y_coords)
|
| 569 |
y_norm = (y_coords - y_min) / (y_max - y_min + 1e-6)
|
| 570 |
|
| 571 |
+
# O PULO DO GATO V37: Espalhamento sai do ponto real calculado pelo KD-Tree
|
| 572 |
+
px, py, pz = st.session_state.p_riser_real
|
| 573 |
+
r_coords = np.sqrt((pts[:, 0] - px)**2 + (pts[:, 2] - pz)**2)
|
| 574 |
r_norm = r_coords / (np.max(r_coords) + 1e-6)
|
| 575 |
|
| 576 |
turbulencia = np.random.normal(0, 0.08, size=mesh_video.n_points)
|
|
|
|
| 583 |
st.session_state.frames_paths = []
|
| 584 |
temp_dir = tempfile.mkdtemp()
|
| 585 |
|
|
|
|
| 586 |
passos = 10
|
| 587 |
|
| 588 |
for i in range(1, passos + 1):
|
|
|
|
| 629 |
st.rerun()
|
| 630 |
|
| 631 |
# ==========================================
|
| 632 |
+
# ETAPA 5: O CINEMA (MUDANÇA DE MARCHA INSTANTÂNEA)
|
| 633 |
# ==========================================
|
| 634 |
elif st.session_state.step == 5:
|
| 635 |
+
st.header("5. Telemetria Cinemática (Câmbio Rápido)")
|
| 636 |
+
st.write(f"Velocidade de Vazamento: **{st.session_state.vel_vaz} m/s** | Cache Dupla Embreagem Ativado")
|
| 637 |
|
| 638 |
if len(st.session_state.frames_paths) > 0:
|
| 639 |
+
# Puxa do HD os 10 frames de uma vez para abastecer a "Caixa de Câmbio" Javascript
|
| 640 |
+
frames_b64 = []
|
| 641 |
+
for p in st.session_state.frames_paths:
|
| 642 |
+
try:
|
| 643 |
+
with open(p, "rb") as f:
|
| 644 |
+
frames_b64.append(base64.b64encode(f.read()).decode())
|
| 645 |
+
except Exception:
|
| 646 |
+
pass
|
|
|
|
|
|
|
| 647 |
|
| 648 |
+
# O segredo: as malhas ficam pré-carregadas neste array gigantesco do lado do Cliente (Navegador)
|
| 649 |
+
frames_js_array = ",\n".join([f'"{b64}"' for b64 in frames_b64])
|
| 650 |
+
|
| 651 |
+
# O controle deslizante (input type range) não se comunica com o Streamlit, ele opera direto na GPU local.
|
| 652 |
+
html_player = f"""
|
| 653 |
+
<html>
|
| 654 |
+
<head>
|
| 655 |
+
<script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/3.4.0/model-viewer.min.js"></script>
|
| 656 |
+
<style>
|
| 657 |
+
body {{ margin: 0; background-color: #f4f6f9; display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; overflow: hidden; font-family: sans-serif; }}
|
| 658 |
+
model-viewer {{ width: 100%; height: 85%; background-color: #1e1e1e; border-radius: 8px; box-shadow: 0 4px 8px rgba(0,0,0,0.3); }}
|
| 659 |
+
.controls {{ height: 15%; display: flex; align-items: center; justify-content: center; width: 100%; gap: 15px; padding: 10px; box-sizing: border-box; }}
|
| 660 |
+
input[type=range] {{ -webkit-appearance: none; width: 60%; background: transparent; }}
|
| 661 |
+
input[type=range]::-webkit-slider-thumb {{ -webkit-appearance: none; height: 24px; width: 24px; border-radius: 50%; background: #ff4500; cursor: pointer; margin-top: -8px; box-shadow: 0 0 5px rgba(0,0,0,0.5); }}
|
| 662 |
+
input[type=range]::-webkit-slider-runnable-track {{ width: 100%; height: 8px; cursor: pointer; background: #cccccc; border-radius: 4px; }}
|
| 663 |
+
.status {{ color: #1e1e1e; font-weight: bold; font-size: 16px; background-color: white; padding: 5px 15px; border-radius: 20px; border: 1px solid #ccc; }}
|
| 664 |
+
</style>
|
| 665 |
+
</head>
|
| 666 |
+
<body>
|
| 667 |
+
<model-viewer id="mv" src="data:model/gltf-binary;base64,{frames_b64[0]}" camera-controls shadow-intensity="1"></model-viewer>
|
| 668 |
+
<div class="controls">
|
| 669 |
+
<span style="font-weight: bold;">Início</span>
|
| 670 |
+
<input type="range" min="1" max="{len(frames_b64)}" value="1" class="slider" id="frameSlider">
|
| 671 |
+
<span style="font-weight: bold;">Fim</span>
|
| 672 |
+
<div class="status" id="frame-counter">Frame: 1 / {len(frames_b64)}</div>
|
| 673 |
+
</div>
|
| 674 |
+
<script>
|
| 675 |
+
// A embreagem: array pesado fica na RAM local, mudança é instantânea
|
| 676 |
+
const frames = [{frames_js_array}];
|
| 677 |
+
const mv = document.getElementById('mv');
|
| 678 |
+
const slider = document.getElementById('frameSlider');
|
| 679 |
+
const counter = document.getElementById('frame-counter');
|
| 680 |
+
|
| 681 |
+
slider.oninput = function() {{
|
| 682 |
+
let idx = this.value - 1;
|
| 683 |
+
mv.src = "data:model/gltf-binary;base64," + frames[idx];
|
| 684 |
+
counter.innerText = "Frame: " + this.value + " / " + frames.length;
|
| 685 |
+
}}
|
| 686 |
+
</script>
|
| 687 |
+
</body>
|
| 688 |
+
</html>
|
| 689 |
+
"""
|
| 690 |
+
components.html(html_player, height=550)
|
| 691 |
else:
|
| 692 |
st.warning("Motor WebGL não encontrou frames no Disco Rígido.")
|
| 693 |
|