多维数据集网格未在指定的div中绘制

时间:2012-09-13 13:44:54

标签: javascript css html5 three.js

我在我的场景中绘制了一个Torus和Cube Mesh,我希望立方体位于屏幕的右下角,所以我喜欢这样:

<div style="position: absolute; bottom: 0px; right:0px; width: 100px; text-align: center; ">
     <script>
         var cube = new THREE.Mesh(new THREE.CubeGeometry(50,50,50),
         new THREE.MeshBasicMaterial({color: 0x000000}));
         scene.add(cube);   
     </script>
</div>

但是,立方体仍然跟随屏幕的中心:http://medigarage.com/html5/js/three.js/examples/canvas_camera2.html

我错过了什么吗?提前完成。

编辑:

我尝试为这个立方体制作新的渲染器,场景和相机:

HTML code:

<div id="share">

CSS代码:

#share  {

             border: 1px solid black; /* or none; */
             margin: 20px;
             padding: 0px;
             width: 200px;
             height: 200px;
             position: absolute;
             right: 0px;
             bottom: 0px;

             }

JavaScript代码:

<script>
        //dom
        var container2=document.getElementById('share');
        //renderer
        var renderer2 = new THREE.CanvasRenderer();
        renderer2.setSize(200,200);
        container2.appendChild(renderer2.domElement);
        //Scene
        var scene2 = new THREE.Scene();
        //Camera
        var camera2 = new THREE.PerspectiveCamera(50,200/200,1,1000);
        camera2.up=camera.up;
        scene2.add(camera2);
        //Axes
        var axes2= new THREE.AxisHelper();
        scene2.add(axes2);
        //Add Cube
        var cube = new THREE.Mesh(new THREE.CubeGeometry(50,50,50),
               new THREE.MeshBasicMaterial({color: 0x000000}));
        scene2.add(cube);
        //

        renderer2.render(scene2,camera2);

        </script>

我把div放在正确的位置,但是多维数据集不存在,在Web控制台中一切正常,我没有得到任何错误。你能指出我的遗漏点吗? 你仍然可以在这里看到它:http://medigarage.com/html5/js/three.js/examples/canvas_camera2.html

1 个答案:

答案 0 :(得分:0)

您可以按照以下示例小提琴执行操作:http://jsfiddle.net/CYMtV/

另见相关主题:https://github.com/mrdoob/three.js/issues/1372