
    Mi,                     r    S r SSKrSSKrSSKJr  SSKJrJr  SS\S\	4S jjr
SS	 jrSS
 jrS\S   4S jrg)zq
notebook.py
-------------

Render trimesh.Scene objects in HTML
and jupyter and marimo notebooks using three.js
    N)Literal   )	resourcesutilescape_quotesreturnc                 n   [         R                  " [        R                  " S5      SS9S   R	                  5       R                  S5      nU R                  nU R                  SS9n[        R                  " U5      R                  S5      nUR                  SU5      nU(       a  UR                  SS	5      $ U$ )
aY  
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/var/www/eduai.edurigo.com/storigo/production/storigo_env/lib/python3.13/site-packages/trimesh/viewer/notebook.pyscene_to_htmlr      s    * 		++,BCuU"	
 
	 	 	A<<%<(Dt$++G4G<<
G,D||C**K    c                     SSK Jn  [        U SS9nUnUR                  SR	                  / SQ5      R                  XQS95      nU$ )a  
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_notebookr/   ;   sR    "   %t<G F
 ||	
 &&
.H Or   c                     SSK n[        U SS9nUR                  SR                  / SQ5      R	                  XAS95      nU$ )a  
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_notebookr4   c   sK    "  d;F
 ww	
 &&
.H Or   )jupyterr1   Fc                  `    [        5       n [        U R                  5      R                  5       nSU;   nS[        R
                  ;   =(       a    S[        R
                  S   ;   nU(       d  U(       d  g SSKnUR                  5       (       a  g g! [         a     N)f = f! [         a     gf = f)	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   spyderr5   r   Nr1   F)	get_ipythonstr	__class__lowerosenvironBaseExceptionr1   running_in_notebook)ipynamer7   r8   r3   s        r   in_notebookrC      s    m 3==!'')% 

"Bx2::c?'B 6!!## $     s$   A0B 4B  
BB 
B-,B-)F)i  )__doc__r   r=   typingr    r   r   boolr:   r   r/   r4   rC    r   r   <module>rI      sL     	  ' ' 'T%P#L%W78 %r   