1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <!DOCTYPE html> <html> <head> <meta charset= "utf-8" > <title>three.jsサンプル</title> <link rel= "stylesheet" href= "css/main.css" > <script src= "../../../js/three.min.js" charset= "utf-8" ></script> </head> <body> <h1>three.jsサンプル</h1> <div id= "result" ></div> <script src= "js/sample.js" ></script> </body> </html> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | // 描画領域、カメラ、ライトの設定 var renderer = new THREE.WebGLRenderer({ antialias: true }); renderer.setSize( 800, 600 ); // サイズを指定 renderer.setClearColor( 0xcfcfff ); // 背景色を指定 document.body.appendChild( renderer.domElement ); // ページ末尾に追加 var camera = new THREE.PerspectiveCamera( 70, 1.0, 1, 1000 ); // カメラ画角などの設定 camera.position.set(0, 0, 40); // カメラ位置の設定 var scene = new THREE.Scene(); // シーンの生成 var light = new THREE.DirectionalLight(0xffffff, 1.25); // ライトを生成 light.position.set(70, 120, 2000); // ライトの位置を設定 scene.add(light); // ライトを追加 // 円(Circle)を生成してシーンに追加 var circle = new THREE.Mesh( new THREE.CircleGeometry( 15, 100, 0, Math.PI ), // 円弧の角度を指定 new THREE.MeshLambertMaterial( { color : 0xff0000 } ) // Lambertで色を指定 ); scene.add(circle); // シーンに円を追加 renderer.render( scene, camera ); // シーンを描画 |