三个js看不到球体

时间:2014-04-22 20:19:09

标签: three.js

我只是看看threejs.org网站上的文档,并且认为我会给一个球体一个镜头,这是我快速嘲笑的:

<!DOCTYPE html>
<html>
    <head>
        <title>Sphere</title>
        <style>canvas { width: 100%; height: 100% }</style>
    </head>
    <body>
        <script type="text/javascript" src="../../threejs/build/Three.js"></script>
        <script>
            var scene = new THREE.Scene();
            var camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 );

            var renderer = new THREE.WebGLRenderer();
            renderer.setSize( window.innerWidth, window.innerHeight );
            document.body.appendChild( renderer.domElement );


            var geometry = new THREE.SphereGeometry(5, 32, 32);
            var material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } );
            var sphere = new THREE.Mesh(geometry, material);
            sphere.overdraw = true;
            scene.add( sphere );

            camera.position.z = 5;

            function render() {                 
                requestAnimationFrame(render); 
                renderer.render(scene, camera); 
            } 

            render();
        </script>
    </body>
</html>

麻烦我看不到球体,控制台也没有错误......有人可以帮助这个。

1 个答案:

答案 0 :(得分:1)

似乎相机位于球体的边缘。试试camera.position.z = 20;