webgl_loader_playcanvas.html 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title>three.js webgl - PlayCanvas</title>
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
  7. <style>
  8. body {
  9. background:#777;
  10. padding:0;
  11. margin:0;
  12. overflow:hidden;
  13. }
  14. #info {
  15. position: absolute;
  16. top: 0px;
  17. width: 100%;
  18. color: #ffffff;
  19. padding: 5px;
  20. font-family:Monospace;
  21. font-size:13px;
  22. text-align:center;
  23. }
  24. a {
  25. color: #ffffff;
  26. }
  27. </style>
  28. </head>
  29. <body>
  30. <div id="container"></div>
  31. <div id="info">
  32. <a href="https://threejs.org" target="_blank" rel="noopener">three.js</a> PlayCanvas loader
  33. | Hand by <a href="https://sketchfab.com/anura" target="_blank" rel="noopener">Anura</a> is licensed under <a href="https://creativecommons.org/licenses/by/4.0/" target="_blank" rel="noopener">CC Attribution</a>
  34. </div>
  35. <script src="../build/three.js"></script>
  36. <script src="js/loaders/PlayCanvasLoader.js"></script>
  37. <script src='js/controls/OrbitControls.js'></script>
  38. <script src="js/Detector.js"></script>
  39. <script src="js/libs/stats.min.js"></script>
  40. <script>
  41. if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
  42. var camera, scene, renderer, stats;
  43. init();
  44. animate();
  45. function init() {
  46. var container = document.getElementById( 'container' );
  47. camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 0.1, 2000 );
  48. camera.position.set( - 1, 2, 4 );
  49. scene = new THREE.Scene();
  50. //
  51. var loader = new THREE.PlayCanvasLoader();
  52. loader.load( './models/playcanvas/hand.json', function ( model ) {
  53. scene.add( model );
  54. } );
  55. //
  56. var ambientLight = new THREE.AmbientLight( 0xcccccc, 0.4 );
  57. scene.add( ambientLight );
  58. var pointLight = new THREE.PointLight( 0xffffff, 0.8 );
  59. camera.add( pointLight );
  60. scene.add( camera );
  61. //
  62. renderer = new THREE.WebGLRenderer();
  63. renderer.setPixelRatio( window.devicePixelRatio );
  64. renderer.setSize( window.innerWidth, window.innerHeight );
  65. container.appendChild( renderer.domElement );
  66. //
  67. var controls = new THREE.OrbitControls( camera );
  68. //
  69. stats = new Stats();
  70. container.appendChild( stats.dom );
  71. //
  72. window.addEventListener( 'resize', onWindowResize, false );
  73. }
  74. function onWindowResize() {
  75. camera.aspect = window.innerWidth / window.innerHeight;
  76. camera.updateProjectionMatrix();
  77. renderer.setSize( window.innerWidth, window.innerHeight );
  78. }
  79. function animate() {
  80. requestAnimationFrame( animate );
  81. render();
  82. stats.update();
  83. }
  84. function render() {
  85. renderer.render( scene, camera );
  86. }
  87. </script>
  88. </body>
  89. </html>