Зацикливает при вставке parseInt О_о
Я новичек. Не судите строго. Вот написал отображение Солнца и Земли в three.js. Захотел вставить перемещение камеры. Ну и вставил через addEventListener, а считывание через parseInt. Вставленный код мыши - закомменченые строки. Но скрип отказывается работать напрочь. Не могу понять уже 2-ой день в чем проблема. Хэлп:help:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>object space</title> <script src="js/three.min.js"></script> </head> <body> <script> var scene, camera, render, container; container = document.createElement('div'); document.body.appendChild(container); // CAMERA ----------------------- camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 1, 300000); camera.position.z = 21000; scene = new THREE.Scene(); // OBJECTS ----------------------- //Sun var sun, sunGeometry, sunMaterial; sunGeometry = new THREE.SphereGeometry(1391, 20, 20); sunMaterial = new THREE.MeshNormalMaterial(); sun = new THREE.Mesh(sunGeometry, sunMaterial); scene.add(sun); //Earth var earth, earthGeometry, earthMaterial; earthGeometry = new THREE.SphereGeometry(13, 10, 10); earthMaterial = new THREE.MeshNormalMaterial(); earth = new THREE.Mesh(earthGeometry, earthMaterial); scene.add(earth); // RENDER ----------------------- render = new THREE.CanvasRenderer(); render.setSize(window.innerWidth, window.innerHeight); container.appendChild(render.domElement); var t = 0; /*var y = 0; document.addEventListener('mousmove',function (event){ y = parseInt(event.offsetY); });*/ animate(); //ANIMATION ----------------------- function animate(){ requestAnimationFrame(animate); sun.rotation.y += 0.0009; earth.position.x = -Math.sin(t*0.001)*15000; earth.position.z = Math.cos(t*0.001)*17000; earth.rotation.y += 0.001; camera.lookAt(scene.position); //camera.position.y += y; t += Math.PI/180*2; render.render(scene, camera); } </script> </body> </html> |
Ошибку нашел. пропущена буква mousEmove. Извиняюсь.
|
Часовой пояс GMT +3, время: 13:11. |