zoukankan      html  css  js  c++  java
  • three.js加入监控

        <!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>  

  • 相关阅读:
    C#文件下载(实现断点续传)
    C#winform实现跑马灯
    Asp.net GridView转换成DataTable
    SQL Server 索引重建脚本
    SQL SERVER数据库维护与重建索引
    python try except 出现异常时,except 中如何返回异常的信息字符串
    UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc3 in position 0: invalid continuation byte
    bower 安装依赖提示 EINVRES Request to https://bower.herokuapp.com/packages/xxx failed with 502
    EINVRES Request to https://bower.herokuapp.com/packages/ failed with 502
    使用notepad++插件远程编辑linux下的配置文件
  • 原文地址:https://www.cnblogs.com/Yimi/p/6016740.html
Copyright © 2011-2022 走看看