View Source
<!-- NOTE: The following source code may contain generated
  content.  You can also use your browser's 'View Source' feature.-->
<html><head><meta charset="utf-8">
<style>
body { margin: 0px; }
canvas { width:100%; height:100%; overflow: hidden; }
</style>
<meta name="viewport" content="user-scalable=no,initial-scale=1,maximum-scale=1">
<script type="text/javascript" src="../h3du_min.js"></script>
<script type="text/javascript" src="demoutil.js"></script><script src="../extras/meshjson.js"></script>
<script type="text/javascript" src="../extras/meshjson.js"></script>
</head>
<body>
<canvas id="canvas"></canvas>
<script id="demo">
/* global H3DU */
// <!--
/*
 Any copyright to this file is released to the Public Domain.
In case this is not possible, this work is also
licensed under the Unlicense: https://unlicense.org/

*/
  // Create the 3D scene; find the HTML canvas and pass it
  // to Scene3D.
  var scene = new H3DU.Scene3D(document.getElementById("canvas"));
  var sub = new H3DU.Batch3D()
   // Set the perspective view. Camera has a 45-degree field of view
   // and will see objects from 0.1 to 100 units away.
   .perspectiveAspect(45, 0.1, 100)
   // Move the camera back 40 units.
   .setLookAt([0, 0, 40]);
  sub.getLights().setBasic();
  // Create a box mesh 10 units in size
  var mesh = H3DU.Meshes.createBox(10, 20, 20);
  // Create a shape based on the mesh and give it a red color
  var shape = new H3DU.Shape(mesh).setColor("red");
  // Add the shape to the scene
  sub.addShape(shape);
  // Create a timer
  var timer = {};
  // Set up the render loop
  H3DU.renderLoop(function(time) {
    "use strict";
   // Update the shape's rotation
    var q = H3DU.Math.quatFromTaitBryan(
     360 * H3DU.getTimePosition(timer, time, 6000),
     360 * H3DU.getTimePosition(timer, time, 12000),
     0
   );
    shape.setQuaternion(q);
   // Render the scene
    scene.render(sub);
  });

// -->
</script>

</body></html>