这个代码在three.js中有什么问题?

时间:2017-12-01 16:08:15

标签: javascript html three.js

我是html和three.js的新手..以下代码无法显示....有人可以协助吗?我认为这可能是帆布的一个问题,但我不确定。

<html>
    <head>
        <title>Test.html</title>
        <style>

            body { margin: 0; }
            canvas { width: 100%; height: 100% }
        </style>

    </head>
    <body>

        <script src="three.min.js"></script>
        <script>

            var scene = new THREE.Scene();

            var camera = new THREE.PerspectiveCamera(45, canvas.width/canvas.height, 1, 30);

            var scene.add(new THREE.DirectionLight(0xffffff, 0.5));

            var model = new THREE.Object3D();

            var geometry = new THREE.CylinderGeometry(2, 2, 10, 16);
            var material = new THREE.MeshBasicMaterial( {color: 0xffff00} )
            var cylinder = new THREE.Mesh(geometry, material);
            model.add(cylinder);
            scene.add(model);

        </script>

    enter code here
    </body>

</html>

0 个答案:

没有答案