夜间模式CodeSnippetStyle:
日间模式CodeSnippetStyle:

0%


《Three.js 入门指南》2.4.1- 照相机 - 透视投影demo

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script type="text/javascript" src="./three.js"></script>
    <title>Document</title>
</head>

<body onload="init()">
    <canvas id="mainCanvas" width="400px" height="300px"></canvas>
</body>
<script>
    function init() {
        var renderer = new THREE.WebGLRenderer({
            canvas: document.getElementById('mainCanvas')
        });
        renderer.setClearColor(0x000000);
        var scene = new THREE.Scene();
        var camera = new THREE.PerspectiveCamera(30, 400 / 300, 1, 10);
        camera.position.set(4, 3, 5);
        scene.add(camera);

        var cube = new THREE.Mesh(new THREE.CubeGeometry(2, 2, 2),
            new THREE.MeshBasicMaterial({
                color: 0xff0000,
                wireframe: true
            })
        );
        scene.add(cube);

        camera.lookAt(new THREE.Vector3(0, 0, 0))
        renderer.render(scene, camera);
    }
</script>

</html>

  

posted @ 2019-12-12 00:02  暮冬有八  阅读(297)  评论(0编辑  收藏  举报
BACK TO TOP

😀迷海无灯听船行。Github WeChat