three.js 官网 https://threejs.org
three.js Github https://github.com/mrdoob/three.js
three.js Book https://github.com/Ovilia/ThreeExample.js
image.png

three.js Git

  1. git clone https://github.com/mrdoob/three.js.git --depth 1
  2. git clone https://github.com/d3/d3.git
  3. // 只克隆最近一次commit
  4. git clone git://URL --depth 1
  5. // depth后,拉取全部历史
  6. git pull --unshallow

three.js用法

  1. <script src="js/three.min.js"></script>
  2. <script>
  3. var camera, scene, renderer;
  4. var geometry, material, mesh;
  5. init();
  6. animate();
  7. function init() {
  8. camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 0.01, 10 );
  9. camera.position.z = 1;
  10. scene = new THREE.Scene();
  11. geometry = new THREE.BoxGeometry( 0.2, 0.2, 0.2 );
  12. material = new THREE.MeshNormalMaterial();
  13. mesh = new THREE.Mesh( geometry, material );
  14. scene.add( mesh );
  15. renderer = new THREE.WebGLRenderer( { antialias: true } );
  16. renderer.setSize( window.innerWidth, window.innerHeight );
  17. document.body.appendChild( renderer.domElement );
  18. }
  19. function animate() {
  20. requestAnimationFrame( animate );
  21. mesh.rotation.x += 0.01;
  22. mesh.rotation.y += 0.02;
  23. renderer.render( scene, camera );
  24. }
  25. </script>

three.js案例