
    Ti,                     p    d Z ddlZddlZddlmZ ddlmZmZ ddede	fd	Z
ddZddZded         fdZdS )zq
notebook.py
-------------

Render trimesh.Scene objects in HTML
and jupyter and marimo notebooks using three.js
    N)Literal   )	resourcesutilFescape_quotesreturnc                    t          j        t          j        d          d          d                                                             d          }| j        }|                     d          }t          j	        |                              d          }|
                    d|          }|r|
                    dd	          S |S )
a  
    Return HTML that will render the scene using
    GLTF/GLB encoded to base64 loaded by three.js

    Parameters
    --------------
    scene : trimesh.Scene
      Source geometry
    escape_quotes
      If true, replaces quotes '"' with '&quot;' so that the
      HTML is valid inside a `srcdoc` property.

    Returns
    --------------
    html : str
      HTML containing embedded geometry
    ztemplates/viewer.zipzip)	file_typezviewer.html.templatezutf-8glbz$B64GLTF"z&quot;)r   
decompressr   	get_bytesreaddecodecameraexportbase64	b64encodereplace)scener   base_dataencodedhtmls          Q/DATA/AppData/hermes/venv/lib/python3.11/site-packages/trimesh/viewer/notebook.pyscene_to_htmlr      s    * 		+,BCCuUUU"	
 
	 	 	A<<%<((Dt$$++G44G<<
G,,D +||C***K      c                     ddl m} t          | d          }|}|                    d                    g d                              ||                    }|S )aM  
    Convert a scene to HTML containing embedded geometry
    and a three.js viewer that will display nicely in
    an IPython/Jupyter notebook.

    Parameters
    -------------
    scene : trimesh.Scene
      Source geometry

    Returns
    -------------
    html : IPython.display.HTML
      Object containing rendered scene
    r   )displayTr   r    z<div><iframe srcdoc="{srcdoc}"z width="100%" height="{height}px"z$style="border:none;"></iframe></div>srcdocheight)IPythonr"   r   HTMLjoinformat)r   r(   kwargsr"   as_htmlr'   embeddeds          r   scene_to_notebookr0   ;   s    "   %t<<<G F
 ||  	
 	
 &v&
.
. H Or   c                     ddl }t          | d          }|                    d                    g d                              ||                    }|S )a7  
    Convert a scene to HTML containing embedded geometry
    and a three.js viewer that will display nicely in
    an Marimo notebook.

    Parameters
    -------------
    scene : trimesh.Scene
      Source geometry

    Returns
    -------------
    html : mo.Html
      Object containing rendered scene
    r   NTr#   r$   r%   r&   )marimor   Htmlr+   r,   )r   r(   r-   mor'   r/   s         r   scene_to_mo_notebookr5   c   ss    "  d;;;F
 ww  	
 	
 &v&
.
. H Or   )jupyterr2   Fc                  B   	 t                      } t          | j                                                  }d|v }dt          j        v odt          j        d         v }|s|sdS n# t          $ r Y nw xY w	 ddl}|                                rdS n# t          $ r Y nw xY wdS )	z
    Check to see if we are in a Jypyter or Marimo notebook.

    Returns
    -----------
    in_notebook
      Returns the type of notebook we're in or False if it
      is running as terminal application.
    terminalr   spyderr6   r   Nr2   F)	get_ipythonstr	__class__lowerosenvironBaseExceptionr2   running_in_notebook)ipynamer8   r9   r4   s        r   in_notebookrD      s    mm 3=!!''))% 
"Bx2:c?'B  	6 	9   !!## 	8	     5s$   AA# #
A0/A04B 
BB)F)r    )__doc__r   r>   typingr    r   r   boolr;   r   r0   r5   rD    r   r   <module>rJ      s      				              ' ' ' ' ' ' 'T% % % %P# # # #L%W78 % % % % % %r   