3
我只是在學習如何做這個three.js的魔法。我可以繪製和製作一個立方體的動畫。但是當我將幾何變成二十面體時,什麼都沒有出現。二十面體幾何體不呈現
在我的js src forlder裏面我只有three.min.js文件。我需要另一個.js文件嗎?
這是我的代碼示例。我只是一個初學者,並且一直花費數小時的時間試圖解決這個問題。請幫忙。
<body>
<script src="js/three.min.js"></script>
<script>
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(75, window.innerWidth/window.innerHeight, 0.1, 1000);
var renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
/*var geometry = new THREE.BoxGeometry(1,1,1);
var material = new THREE.MeshLambertMaterial({color: 0x00ff00});
var cube = new THREE.Mesh(geometry, material);
scene.add(cube);*/
var geometry = new THREE.IcosahedronGeometry(200,1);
var material = new THREE.MeshBasicMaterial({ color: 0x00ff00, wireframe: false, wireframeLinewidth: 2 });
var mesh = new THREE.Mesh(geometry, material);
scene.add(mesh);
var pointlight = new THREE.PointLight(0xffffff);
pointlight.position.x = 10;
pointlight.position.y = 50;
pointlight.position.z = 1000;
scene.add(pointlight)
camera.position.z = 5;
var render = function() {
requestAnimationFrame(render);
cube.rotation.x += .01;
cube.rotation.y += .01;
renderer.render(scene, camera);
};
render();
</script>
</body>
你的相機是在對象內部。你有一個200的半徑。 – gaitat 2014-09-25 19:39:35
是。我是個白癡。謝謝 – fkgomez 2014-09-25 20:14:56