我只是 webGL 和 three.js 的新手,我刚刚从 JSFiddle 中挑选了一个例子,
http://jsfiddle.net/BlackSRC/XWCRM/1/
但是当我测试它时,我什么也没得到,代码看起来像这样:
<!DOCTYPE html>
<html>
<head>
<title>ThreeJS</title>
</head>
<script src="~/Scripts/jquery-1.9.1.js"></script>
<script src="~/Scripts/mrdoob-three.js-2524525/build/three.js"></script>
<script>
function onLoadComplete() {
init();
animate();
}
var camera, scene, renderer;
var geometry, material, mesh;
function init() {
camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 1, 10000);
camera.position.z = 1000;
scene = new THREE.Scene();
geometry = new THREE.CubeGeometry(200, 200, 200);
material = new THREE.MeshBasicMaterial({ color: 0xff0000, wireframe: true });
mesh = new THREE.Mesh(geometry, material);
scene.add(mesh);
renderer = new THREE.CanvasRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
}
function animate() {
// note: three.js includes requestAnimationFrame shim
requestAnimationFrame(animate);
mesh.rotation.x += 0.01;
mesh.rotation.y += 0.02;
renderer.render(scene, camera);
}
</script>
<body onload="onLoadComplete();">
我错过了什么吗?感谢您的帮助!