##################################################
Viewing and Interrogating 3D Models in the Browser
##################################################

Advanced Publishing can be used to view and interrogate 3D models in a browser using standard web technologies without the help of any plug-ins.

This section addresses how to use the StreamCache file format to view files in a browser.

.. _toc_client_server_mode_and_stream_cache:

Client/Server Mode and Stream Cache
===================================

In client/server mode, you will start by exporting a stream cache single file (scs).

The SCS file will then be parsed and displayed in the browser by a client web viewer that we provide as part of Advanced Publishing. See the samples directory in the package download: *samples\\data\\publishhtml\\htmlforserver*.

The web viewer is a combination of JavaScript, WebGL, CSS, and HTML. It can be used to load SCS files in a browser from a web server.

To help test this functionality, we have provided a simple HTTP server that can be launched by clicking on *samples\\data\\publishhtml\\htmlforserver\\export3dtohtml\\start_server.bat* .

Once the server is launched, open the following URL in your browser: ``localhost:11180/hoops_web_viewer.html?scs=helloworld.scs`` .

*hoops_web_viewer.html* can load any SCS file; to change the file you're viewing, simply change the query string "scs=helloworld.scs" in the URL with the new file name.

To generate an SCS file, use the ``A3DExport`` data structure. ``A3DRWParamsExportScsData`` can be used to include exact measurement information that will be re-used by the web viewer.

.. code-block:: c

   A3DExport sExport("helloworld.scs");
   A3DStatus iRet = sHoopsExchangeLoader.Export(sExport);

Please note, *hoops_web_viewer.html* can be customized to include your own content or logo. If you need to further customize the 3D viewer component, you might consider using HOOPS Visualize Web. Please `contact us <https://pages.techsoft3d.com/connect-with-us>`_ for more information.

.. _toc_monolithic_file_and_stream_cache:

Monolithic File and Stream Cache
================================

Advanced Publishing can also be used to generate a monolithic HTML file. In this mode, the 3D web viewer, JavaScript libraries, SCS files, and CSS files are all embedded in one HTML file.

One of the primary advantages of the monolithic file is that it can be used to share data without having to use an HTTP server. The downside is that much of the data embedded in the HTML file has to be sent for each 3D model to share. Also, this mode does not leverage the cache mechanism from the server.

The Monolithic HTML export works like any export functionality:

.. code-block:: c

  // specify output file
  A3DExport sExport(OUT_FILE_HTML);
  sExport.m_sExportHtmlData.m_bIncludeMeasurementInformation = false;
  sExport.m_sExportHtmlData.m_pcHtmlTemplateName = IN_FILE_HTMLTEMPLATE;
  // conversion is performed
  iRet = sHoopsExchangeLoader.Convert(sImport, sExport);


``A3DRWParamsExportHtmlData`` can be used to include information that will be used with the measurement tool in the web viewer.

A default template is included in the Advanced Publishing package to export 3d model: *samples\\data\\html\\export3dtohtml_template.html*. It can be used and referenced by the  ``A3DRWParamsExportHtmlData`` structure.

You can use this HTML page to customize your own page - for instance, you can embed your own content, objects, logo, etc.

If you need more advanced customization of the 3D viewer component, you might consider using HOOPS Visualize Web. Please :doc:`contact us </contact_us>` to learn more about these products.

Another template file (*samples\\data\\html\\export3dtohtml_template_custom.html*) is given as an example of customization. If you wish to customize the 3D export to HTML, you could draw your inspiration from it.

