Slides 3D interactives

Présentations complètes

Les exemples précédents placent une démo dans une slide. Dans un exposé, les démos sont mêlées au reste de la présentation : un titre, un plan, des sections, des slides de texte, et de temps en temps une slide avec une démo à côté de son texte. Les deux présentations ci-dessous sont le même exposé de douze slides, réalisé une fois avec reveal.js et une fois avec lhtml-site, avec les démos des exemples.

Dans les deux, passez d'une slide à l'autre avec les flèches ; cliquez dans une démo pour la tourner, puis les flèches passent toujours à la slide suivante. Les présentations sont en anglais.

En reveal.js

En direct : cliquez dans la présentation, puis utilisez les flèches. L'ouvrir dans sa propre page.
Télécharger : talk-reveal.zip, la présentation et ses démos (demos/), prête à montrer (voir son README.md).La montrer : python3 -m http.server 8080 dans son dossier, puis http://localhost:8080/

Un seul fichier HTML contient toute la présentation, une <section> par slide. Les démos sont dans demos/ à côté :

talk-reveal/
  README.md              how to show it
  index.html             the presentation, below
  demos/
    a1/ a2/ c3/ c6/ c7/  the web builds of the examples: index.html, project.js, project.wasm, project.data
    slide-controls.js    the buttons of the slides
  • Une slide avec une démo : un <div class="side"> avec le texte à gauche et le cadre à droite.
  • data-src charge une démo quand sa slide approche, et la décharge ensuite : les démos des autres slides ne tournent pas.
  • Toutes les slides sont dans une même page : les boutons d'une slide nomment leur démo (data-demo="#surface").

index.html

index.html

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Interactive 3D in a talk</title>
<!--
  An example talk of the tutorial "Create slides with interactive 3D", made with reveal.js: twelve
  slides, with titles, text, and interactive 3D models in some of them.

  The demos are in demos/<name>/ next to this file (the web builds of the examples: index.html,
  project.js, project.wasm, project.data), with slide-controls.js. Each one is a plain <iframe>;
  data-src loads it when its slide comes near and unloads it after. All the slides are in this page:
  the buttons of a slide name their demo (data-demo="#surface").

  Open it through a web server: python3 -m http.server 8080 in this folder, then http://localhost:8080/
  reveal.js comes from a CDN: for a talk without network, download it next to this file.
-->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/reveal.js@5.1.0/dist/reveal.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/reveal.js@5.1.0/dist/theme/white.css">
<style>
  /* the text on the left, the demo on the right */
  .reveal .side { display: grid; grid-template-columns: 40% 60%; gap: 30px; align-items: center; text-align: left; }
  .reveal .side ul { font-size: 0.75em; margin: 0; }
  .reveal .side p { font-size: 0.75em; }
  .reveal iframe.demo { width: 100%; height: 520px; border: 0; }
  .reveal code { font-size: 0.85em; }
  .reveal .muted { color: #888; font-size: 0.6em; }
  /* the buttons of the slides, and the current state of the demo (class on) */
  .reveal .controls-row button { font: inherit; font-size: 0.7em; padding: 4px 14px; margin: 0 6px 8px 0;
                                 border-radius: 8px; border: 2px solid #999; background: white; cursor: pointer; }
  .reveal .controls-row button.on { background: #333; color: white; border-color: #333; }
  .reveal .value { font-weight: bold; color: #c0392b; }
</style>
</head>
<body>
<div class="reveal"><div class="slides">

<section>
  <h2>Interactive 3D in a talk</h2>
  <p>An example presentation, made with reveal.js</p>
  <p class="muted">Tutorial: Create slides with interactive 3D</p>
</section>

<section>
  <h3>Outline</h3>
  <p style="font-size: 0.7em">The demos of this talk are C++ programs (OpenGL 3.3), compiled to WebAssembly:
  each one runs in a frame of the slide, next to the text.</p>
  <ol>
    <li>A demo in the slide</li>
    <li>Settings and controls</li>
    <li>Values from the program</li>
  </ol>
  <p class="muted">Click in a demo to turn it with the mouse; the arrow keys still go to the next slide.</p>
</section>

<section><h2>1. A demo in the slide</h2></section>

<section>
  <h3>A C++ program in the slide</h3>
  <div class="side">
    <ul>
      <li>A program in raw OpenGL 3.3, about 200 lines</li>
      <li>Compiled to WebAssembly with Emscripten</li>
      <li>Shown by the slide in an <code>&lt;iframe&gt;</code></li>
      <li>Set by the address of the frame: <code>?speed=0.2&amp;tilt=25</code></li>
    </ul>
    <iframe class="demo" data-src="demos/a1/index.html?speed=0.2&tilt=25"></iframe>
  </div>
</section>

<section>
  <h3>The same program, another preset</h3>
  <div class="side">
    <ul>
      <li>The same build as the previous slide</li>
      <li>Another address: <code>?speed=0.5&amp;tilt=-30&amp;background=dark</code></li>
      <li>One build serves all the slides that show this demo</li>
    </ul>
    <iframe class="demo" data-src="demos/a1/index.html?speed=0.5&tilt=-30&background=dark"></iframe>
  </div>
</section>

<section><h2>2. Settings and controls</h2></section>

<section>
  <h3>A panel built from the program</h3>
  <div class="side">
    <ul>
      <li>The program declares its parameters, with their ranges</li>
      <li>The page of the demo builds the panel from them</li>
      <li>Each slider changes a uniform while the demo turns</li>
    </ul>
    <iframe class="demo" data-src="demos/a2/index.html?twist=0.8&controls=twist,hue,speed,light,reset"></iframe>
  </div>
</section>

<section>
  <h3>Buttons in the slide</h3>
  <div class="side">
    <div>
      <p>The buttons below are in the text of the slide, outside the frame.</p>
      <div class="controls-row">
        <button data-demo="#surface" data-demo-set="shape=ripple">Ripple</button>
        <button data-demo="#surface" data-demo-set="shape=waves">Waves</button>
        <button data-demo="#surface" data-demo-set="drop">Drop</button>
        <button data-demo="#surface" data-demo-set="ampl=0.25&amp;k=14">Strong</button>
      </div>
      <p>Amplitude: <span class="value" data-demo="#surface" data-demo-value="ampl" data-digits="2"></span></p>
    </div>
    <iframe class="demo" id="surface" data-src="demos/c3/index.html?controls=ampl,k,speed&panel=bl"></iframe>
  </div>
</section>

<section>
  <h3>An ImGui window</h3>
  <div class="side">
    <div>
      <ul>
        <li>Marching cubes on a scalar field, recomputed at each change</li>
        <li>The interface is the ImGui window of the program</li>
        <li>Its text is enlarged by the address: <code>?gui_scale=1.4</code></li>
      </ul>
      <div class="controls-row">
        <button data-demo="#marching" data-demo-set="power_c=1.2">Third blob</button>
        <button data-demo="#marching" data-demo-set="isovalue=0.3">Larger</button>
        <button data-demo="#marching" data-demo-set="power_c=0&amp;isovalue=0.5">Back</button>
      </div>
    </div>
    <iframe class="demo" id="marching" data-src="demos/c6/index.html?gui_scale=1.4"></iframe>
  </div>
</section>

<section><h2>3. Values from the program</h2></section>

<section>
  <h3>The slide shows a value of the program</h3>
  <div class="side">
    <div>
      <p>Drag a blue point: the program computes the length of the curve, and the slide shows it.</p>
      <p>Length of the curve: <span class="value" data-demo="#curve" data-demo-value="length" data-digits="2"></span></p>
      <div class="controls-row">
        <button data-demo="#curve" data-demo-set="curve=bezier">B&eacute;zier</button>
        <button data-demo="#curve" data-demo-set="curve=spline">Spline</button>
      </div>
    </div>
    <iframe class="demo" id="curve" data-src="demos/c7/index.html?controls=points,polygon,reset&panel=br"></iframe>
  </div>
</section>

<section>
  <h3>Conclusion</h3>
  <ul style="font-size: 0.75em">
    <li>A 3D demo in a slide is a web page in a frame</li>
    <li>The address of the frame sets it, slide by slide</li>
    <li>A panel, buttons in the slide or ImGui drive it during the talk</li>
    <li>The program can send values back to the slide</li>
  </ul>
  <p style="font-size: 0.7em">The method, the code of these demos and of this talk: the tutorial
  <a href="https://scholartools.fr/interactive-3d-slides/">Create slides with interactive 3D</a>.</p>
</section>

</div></div>
<script src="https://cdn.jsdelivr.net/npm/reveal.js@5.1.0/dist/reveal.js"></script>
<script src="demos/slide-controls.js"></script>
<script>
  Reveal.initialize({hash: true});
  // After a click in a demo, the keyboard stays in its frame. When the slide changes, reveal.js
  // unloads that demo (data-src): the frame keeps the keyboard but becomes an empty page, which
  // sends no key back, and the next arrow would be lost. The presentation takes the keyboard back.
  Reveal.on('slidechanged', () => {
    if (document.activeElement && document.activeElement.tagName === 'IFRAME') document.activeElement.blur();
  });
</script>
</body>
</html>

En lhtml-site

En direct : cliquez dans la présentation, puis utilisez les flèches. L'ouvrir dans sa propre page, ou son PDF.
Télécharger : talk-lhtml-site.zip, les sources de la présentation et ses démos (src/_demo/)La construire : lhtml-site dans son dossier, puis lhtml-site --serve

Un dossier par slide, dans l'ordre de leurs noms. Les démos sont dans src/_demo/ ; un dossier dont le nom commence par un tiret bas n'est pas une slide, il est copié tel quel.

talk-lhtml-site/
  README.md                    how to build and show it
  configure.yaml               the build: the slides in the browser, and a PDF
  src/
    01_title/index.html.j2     a slide: its title (=), its text, its model (demo::)
    02_outline/index.html.j2
    ...
    12_conclusion/index.html.j2
    _style/talk.css            the buttons of the slides, and the image of a model in the PDF
    _demo/a1/ ... _demo/c7/    the web builds of the examples, with their poster
    _demo/slide-controls.js
  • Une slide avec une démo : la mise en page side met le texte à gauche et le bloc media:: à droite.
  • demo:: écrit le cadre ; img:: donne l'image de la démo dans le PDF (les classes .live et .still, et _style/talk.css).
  • Une slide montre une page : les boutons d'une slide pilotent sa démo sans la nommer.
  • configure.yaml charge la feuille de style et slide-controls.js dans chaque slide (cssAbs, jsAbs).

configure.yaml

# An example talk of the tutorial "Create slides with interactive 3D", made with lhtml-site:
# twelve slides, with titles, text, and interactive 3D models in some of them.
#
#   lhtml-site                   build into .site/: html/ in the browser, slides.pdf
#   lhtml-site --serve --watch   preview on http://127.0.0.1:8000/
#
# The demos are in src/_demo/<name>/ (the web builds of the examples: index.html, project.js,
# project.wasm, project.data, poster.png), with slide-controls.js; a folder whose name starts with an
# underscore is not a slide, it is copied as it is.
source_directory: 'src/'
site_directory: '.site/'
targets:
  html: {theme: slides}
  pdf: {theme: slides-pdf}
keywords:
  cssAbs: [_style/talk.css]              # the buttons of the slides, and the image of a demo in the PDF
  jsAbs: [_demo/slide-controls.js]       # the buttons of the slides drive their demo

src/_style/talk.css

/* The buttons written in the slides (data-demo-set), and the current state of the demo (class on) */
.controls button { font: inherit; font-size: 80%; padding: 4px 16px; margin: 0 8px 8px 0; cursor: pointer;
                   border: 2px solid #999; border-radius: 8px; background: white; }
.controls button.on { background: #333; color: white; border-color: #333; }
.value { font-weight: bold; color: #c0392b; }

/* On screen the demo, in the PDF its image (the PDF is printed by the browser) */
@media screen { .still { display: none; } }
@media print { .live, .controls { display: none; } }

Les douze slides

src/01_title/index.html.j2

{% set layout = 'section' %}

= Interactive 3D in a talk

An example presentation, made with lhtml-site

muted:: Tutorial: Create slides with interactive 3D ::

src/02_outline/index.html.j2

= Outline

The models of this talk are C++ programs (OpenGL 3.3), compiled to WebAssembly: each one runs in a
frame of the slide, next to the text.

<ol>
<li>A model in the slide</li>
<li>Settings and controls</li>
<li>Values from the program</li>
</ol>

gap::

small:: Click in a model to turn it with the mouse; the arrow keys still go to the next slide. ::

src/03_part-model/index.html.j2

{% set layout = 'section' %}

= 1. A model in the slide

src/04_program/index.html.j2

{% set layout = 'side' %}

= A C++ program in the slide

* A program in raw OpenGL 3.3, about 200 lines
* Compiled to WebAssembly with Emscripten
* Shown by the slide in a frame (`demo::`)
* Set by the address of the frame: `?speed=0.2&tilt=25`

media::
demo::../_demo/a1/index.html?speed=0.2&tilt=25(.live)
img::../_demo/a1/poster.png(.still)
::

src/05_preset/index.html.j2

{% set layout = 'side' %}

= The same program, another preset

* The same build as the previous slide
* Another address: `?speed=0.5&tilt=-30&background=dark`
* One build serves all the slides that show this model

media::
demo::../_demo/a1/index.html?speed=0.5&tilt=-30&background=dark(.live)
img::../_demo/a1/poster.png(.still)
::

src/06_part-controls/index.html.j2

{% set layout = 'section' %}

= 2. Settings and controls

src/07_panel/index.html.j2

{% set layout = 'side' %}

= A panel built from the program

* The program declares its parameters, with their ranges
* The page of the demo builds the panel from them
* Each slider changes a uniform while the model turns

small:: Address of the frame: `?twist=0.8&controls=twist,hue,speed,light,reset` ::

media::
demo::../_demo/a2/index.html?twist=0.8&controls=twist,hue,speed,light,reset(.live)
img::../_demo/a2/poster.png(.still)
::

src/08_buttons/index.html.j2

{% set layout = 'side' %}

= Buttons in the slide

The buttons below are in the text of the slide, outside the frame.

<div class="controls">
<p>
<button data-demo-set="shape=ripple">Ripple</button>
<button data-demo-set="shape=waves">Waves</button>
<button data-demo-set="drop">Drop</button>
<button data-demo-set="ampl=0.25&amp;k=14">Strong</button>
</p>
<p>Amplitude: <span class="value" data-demo-value="ampl" data-digits="2"></span></p>
</div>

media::
demo::../_demo/c3/index.html?controls=ampl,k,speed&panel=bl(.live)
img::../_demo/c3/poster.png(.still)
::

src/09_imgui/index.html.j2

{% set layout = 'side' %}

= An ImGui window

* Marching cubes on a scalar field, recomputed at each change
* The interface is the ImGui window of the program
* Its text is enlarged by the address: `?gui_scale=1.4`

<div class="controls">
<p>
<button data-demo-set="power_c=1.2">Third blob</button>
<button data-demo-set="isovalue=0.3">Larger</button>
<button data-demo-set="power_c=0&amp;isovalue=0.5">Back</button>
</p>
</div>

media::
demo::../_demo/c6/index.html?gui_scale=1.4(.live)
img::../_demo/c6/poster.png(.still)
::

src/10_part-values/index.html.j2

{% set layout = 'section' %}

= 3. Values from the program

src/11_readout/index.html.j2

{% set layout = 'side' %}

= The slide shows a value of the program

Drag a blue point: the program computes the length of the curve, and the slide shows it.

<div class="controls">
<p>Length of the curve: <span class="value" data-demo-value="length" data-digits="2"></span></p>
<p>
<button data-demo-set="curve=bezier">B&eacute;zier</button>
<button data-demo-set="curve=spline">Spline</button>
</p>
</div>

media::
demo::../_demo/c7/index.html?controls=points,polygon,reset&panel=br(.live)
img::../_demo/c7/poster.png(.still)
::

src/12_conclusion/index.html.j2

= Conclusion

* A 3D model in a slide is a web page in a frame
* The address of the frame sets it, slide by slide
* A panel, buttons in the slide or ImGui drive it during the talk
* The program can send values back to the slide
* In the PDF of the talk, an image of each model

gap::

The method, the code of these models and of this talk: the tutorial
link::https://scholartools.fr/interactive-3d-slides/[Create slides with interactive 3D].

Le même exposé dans les deux

reveal.js lhtml-site
Les slides un fichier HTML, une <section> par slide un dossier par slide, index.html.j2
Une démo <iframe class="demo" data-src="demos/c3/index.html?..."> demo::../_demo/c3/index.html?...
Texte et démo côte à côte une grille dans le style de la page la mise en page side
Les boutons d'une slide nomment leur démo : data-demo="#surface" pilotent la démo de la slide
Le PDF l'impression de reveal.js slides-pdf, avec une image de chaque démo

Ensuite : Votre propre programme dans une slide, puis Le jour de l'exposé.