Texture courtesy of pdtextures.blogspot.com
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="../extras/frame.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> <p>Texture courtesy of pdtextures.blogspot.com</p> <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")) .cullFace(H3DU.Scene3D.BACK) .setClearColor("white") 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(); var fc = new H3DU.FrameCounterDiv(); var loader = new H3DU.TextureLoader(); loader.loadAndMapTexturesAll([ "461223191.jpg" ], scene).then(function(tex) { "use strict"; var mesh = H3DU.Meshes.createBox(10, 20, 20); var shape = new H3DU.Shape(mesh).setTexture(tex[0]); sub.addShape(shape); // Create a timer var timer = {}; // Set up the render loop H3DU.renderLoop(function(time) { // Update the shape's rotation var q = H3DU.MathUtil.quatFromTaitBryan( 360 * H3DU.getTimePosition(timer, time, 6000), 360 * H3DU.getTimePosition(timer, time, 12000), 0 ); fc.update(); shape.setQuaternion(q); // Render the scene scene.render(sub); }); }); // --> </script> </body></html>