three.js加入監控

來源:互聯網
上載者:User

標籤:n+1   lib   xca   three.js   one   append   ec2   awd   point   

    <!DOCTYPE html>      <html>          <head>              <meta charset="UTF-8">              <title>Three架構</title>              <script type="text/javascript" script src="libs/three.js"></script>              <script type="text/javascript" script src="libs/stats.min.js"></script>                    <style type="text/css">                  div#canvas-frame {                      border: none;                      cursor: pointer;                      width: 100%;                      height: 600px;                      background-color: #EEEEEE;                  }              </style>                    <script>                  var renderer;                  var stats;                  function initThree() {                      width = document.getElementById(‘canvas-frame‘).clientWidth;                      height = document.getElementById(‘canvas-frame‘).clientHeight;                      renderer = new THREE.WebGLRenderer({ antialias : true });                      renderer.setSize(width, height);                      document.getElementById(‘canvas-frame‘).appendChild(renderer.domElement);                      renderer.setClearColor(0xFFFFFF, 1.0);                                                stats = new Stats();  //stats對象初始化                      stats.domElement.style.position = ‘absolute‘; //將stats對象加入到html網頁中,絕對座標                      stats.domElement.style.left = ‘0px‘;// (0,0)px,左上方                      stats.domElement.style.top = ‘0px‘;                      document.getElementById(‘canvas-frame‘).appendChild(stats.domElement);                  }                        var camera;                  function initCamera() {                      camera = new THREE.PerspectiveCamera(45, width / height, 1, 10000);                      camera.position.x = 0;                      camera.position.y = 0;                      camera.position.z = 600;                      camera.up.x = 0;//camera.up 設定相機的傾斜角度,歪著拿相機,照片自然也不是水平的                      camera.up.y = 0;                      camera.up.z = 0;                      camera.lookAt({ //鏡頭看著哪裡呢?景物在動                          x : 0,                          y : 0,                          z : 0                      });                  }                        var scene;                  function initScene() {                      scene = new THREE.Scene();                  }                        var light;                  function initLight() {                      light = new THREE.PointLight(0x00FF00);                      light.position.set(0, 0,300);                      scene.add(light);                  }                        var cube;                  var mesh;                  function initObject() {                                        var geometry = new THREE.CylinderGeometry( 10,15,40);                      var material = new THREE.MeshLambertMaterial( { color:0xFFFFFF} );                      mesh = new THREE.Mesh( geometry,material);                      mesh.position.x = 100;                      mesh.position.y = 100;                      mesh.position.z = 100;                      scene.add(mesh);                           }                        function threeStart() {                      initThree();                      initCamera();                      initScene();                      initLight();                      initObject();                      animation();                  }                        function animation()                  {                      mesh.position.z+=1;                      renderer.render(scene, camera);                      requestAnimationFrame(animation);                      stats.update();//這個函數真好用                  }              </script>          </head>                <body onload="threeStart();">              <div id="canvas-frame"></div>          </body>      </html>  

three.js加入監控

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.