Skip to content

Instantly share code, notes, and snippets.

@winwu
Created July 2, 2013 15:38
Show Gist options
  • Save winwu/5910380 to your computer and use it in GitHub Desktop.
Save winwu/5910380 to your computer and use it in GitHub Desktop.
學習three.js 002
<!DOCTYPE HTML>
<html lang="zh-TW">
<head>
<meta charset="UTF-8">
<title>我的第一個three.js-002.html</title>
<style>
canvas{width:100%; height:100%}
</style>
</head>
<body>
<script src="https://rawgithub.com/mrdoob/three.js/master/build/three.js"></script>
<script>
/*
*(1)
*在我們開始使用three.js之前,有個觀念,要大家先知道的
*有三個必備的元素:
* (A)就是001.html所提及的,我們需要一個場景(scene)
* (B)一台相機(camera)
* (C)一個渲染器(renderer),這個渲染器可以將相機拍的東西顯示在場景(scene)上
*/
//以下範例是模仿three.org網站的Manual,可同時參考 http://threejs.org/docs/58/#Manual/Introduction/Creating_a_scene
//首先讓我們用three.js實例化一個場景(scene)
var scene = new THREE.Scene();
//接著實例化一台相機,暫且先不解釋ProspectiveCamera的args
//ProspectiveCamera(視野的大小fov, 寬高的比例aspect,相機離視體最近的距離near ,相機離視體最遠的距離far );
//http://www.html5china.com/HTML5features/WebGL/20120509_3611.html
var camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 );
//實例化渲染器
var renderer = new THREE.WebGLRenderer();
//渲染器設定大小
renderer.setSize( window.innerWidth, window.innerHeight );
//將渲染器插入到body標籤裡
document.body.appendChild ( renderer.domElement);
//設定完成,003.html,會開始實做在畫面上畫一個cube(立方體)!
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment