创建一个WebG锥Three.js文件,我们可以实例化一个CylinderGeometry对象通过顶端半径设置为零,定义底部半径、高度,通过segmentsRadius和segmentsHeight参数的详细级别。增加segmentsWidth和segmentsHeight将产生一个更加完美的汽缸但可能降低性能。减少segmentsWidth和segmentsHeight将产生一个不太完美的锥,但可能有助于性能。
<!DOCTYPE HTML>
<html>
<head>
<style>
body {
margin: 0px;
padding: 0px;
}
</style>
</head>
<body>
<div id="container"></div>
<script src="http://www.html5canvastutorials.com/libraries/three.min.js"></script>
<script defer="defer">
// revolutions per second
var angularSpeed = 0.2;
var lastTime = 0;
// this function is executed on each animation frame
function animate(){
// update
var time = (new Date()).getTime();
var timeDiff = time - lastTime;
var angleChange = angularSpeed * timeDiff * 2