案例:Three 顶点3-只有线段     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<!DOCTYPE html>
2
<html>
3
<head>
4
  <meta charset="UTF-8">
5
  <style>
6
    body {
7
      margin: 0;
8
      overflow: hidden;
9
      /* 隐藏body窗口区域滚动条 */
10
    }
11
  </style>
12
  <!--引入three.js三维引擎-->
13
  <script src="/js/threejs/threer92.js"></script>
14
  <script src="/example/threejs/solarsystem/files/OrbitControls.js"></script>
15
</head>
16
17
<body>
18
  <script>
19
    //创建场景
20
    var scene = new THREE.Scene();
21
22
    //创建一个Buffer类型几何体对象
23
    var geometry = new THREE.BufferGeometry();
24
    //类型数组创建顶点数据
25
    var vertices = new Float32Array([
26
        0, 0, 0, //顶点1坐标
27
        50, 0, 0, //顶点2坐标
28
        0, 100, 0, //顶点3坐标
29
        0, 0, 10, //顶点4坐标
30
        0, 0, 100, //顶点5坐标
31
        50, 0, 10, //顶点6坐标
32
    ]);
33
    // 创建属性缓冲区对象
34
    var attribue = new THREE.BufferAttribute(vertices, 3); //3个为一组,表示一个顶点的xyz坐标
35
    // 设置几何体attributes属性的位置属性
36
    geometry.attributes.position = attribue;
37
    // 线条渲染模式
38
    var material=new THREE.LineBasicMaterial({
39
        color:0xff0000 //线条颜色
40
    });//材质对象
41
    var line=new THREE.Line(geometry,material);//线条模型对象
42
    scene.add(line);//线条对象添加到场景中
43
    
44
      
45
    /**
46
     * 光源设置
47
     */
48
    //点光源