• three.js 之旅 (二)


    three.js中各种场景的使用方法:

      当然首先要先引入three.js库;其次,手动定义一个 canvas 标签。

      <script type="text/javascript" src="../bower_components/three/three.js"></script>
      <canvas id="test1" width="400" height="300"></canvas>

    1. 创建渲染器renderer:

      var renderer = new THREE.WebGLRenderer({

      canvas:document.getElementById("test1")
      });
      renderer.setClearColor('#000');

    2. 创建场景:
      var scene = new THREE.Scene();

    3. 创建照相机
      (创建透视照相机):
       var camera = new THREE.PerspectiveCamera(45,4/3,0.1,6000);

       camera.position.set(0,0,8);
       scene.add(camera);
    (创建正交照相机):
      var camera = new THREE.OrthographicCamera(-2,2,1.5,-1.5,1,10);
      camera.position.set(4,3,5);
      camera.lookAt(scene.position);
    4.创建模型:
      var cube = new THREE.Mesh(new THREE.CubeGeometry(1,2,3),
    new THREE.MeshBasicMaterial({
    color :'#ccc',
    wireframe:true
    })
      );
    5.将创建的对象添加到场景中:
      
      scene.add(cube);
      renderer.render(scene,camera);

      
     

      

  • 相关阅读:
    c++ Knight Moves 超级升级版
    百度招聘彩蛋
    C++ 八数码问题宽搜
    c++ 动态规划(数塔)
    c++ 深度优先搜索(迷宫)
    c++ 宽搜(倒水)
    c++ matrix逆时针螺旋
    c++ 基数排序
    c++ 二分答案(解方程)
    c++ 二分答案(数组查找)
  • 原文地址:https://www.cnblogs.com/ssrsblogs/p/5611129.html
Copyright © 2020-2023  润新知