瀏覽代碼

use controls from three.js.

Lucas Stadler 12 年之前
父節點
當前提交
3133c0b5f5
共有 3 個文件被更改,包括 11 次插入9 次删除
  1. 1 0
      js/pixl/.gitignore
  2. 2 1
      js/pixl/Makefile
  3. 8 8
      js/pixl/public/thrixl.html

+ 1 - 0
js/pixl/.gitignore

@ -2,5 +2,6 @@
2 2
3 3
public/glmatrix.js
4 4
public/three.js
5
public/three.flycontrols.js
5 6
6 7
.server.log

+ 2 - 1
js/pixl/Makefile

@ -6,4 +6,5 @@ fetch_live:
6 6
7 7
fetch_deps:
8 8
	curl -o public/glmatrix.js https://raw.github.com/toji/gl-matrix/master/dist/gl-matrix.js
9
	curl -o public/three.js https://rawgithub.com/mrdoob/three.js/master/build/three.min.js
9
	curl -o public/three.js https://raw.github.com/mrdoob/three.js/master/build/three.min.js
10
	curl -o public/three.flycontrols.js https://raw.github.com/mrdoob/three.js/master/examples/js/controls/FlyControls.js

+ 8 - 8
js/pixl/public/thrixl.html

@ -14,6 +14,7 @@
14 14
15 15
<body>
16 16
	<script src="three.js"></script>
17
	<script src="three.flycontrols.js"></script>
17 18
	<script src="geometry.js"></script>
18 19
	<script>
19 20
		window.trixl = {};
@ -143,6 +144,10 @@
143 144
		var camera = new THREE.PerspectiveCamera(75, aspect, 0.1, 1000);
144 145
		camera.position.z = 10;
145 146
147
		var controls = new THREE.FlyControls(camera);
148
		controls.movementSpeed = 5.0;
149
		controls.rollSpeed = 0.75;
150
146 151
		var renderer = new THREE.WebGLRenderer();
147 152
		renderer.sortObjects = false;
148 153
		renderer.setClearColor(0xffffff);
@ -153,6 +158,8 @@
153 158
		group.frustumCulled = false;
154 159
		scene.add(group);
155 160
161
		var clock = new THREE.Clock();
162
156 163
		var render = function() {
157 164
			requestAnimationFrame(render);
158 165
@ -166,19 +173,12 @@
166 173
				}
167 174
			}
168 175
176
			controls.update(clock.getDelta());
169 177
			renderer.render(scene, camera);
170 178
		}
171 179
172 180
		render();
173 181
174
		document.addEventListener("keydown", function(ev) {
175
			if (ev.keyCode == 87) {
176
				camera.position.z -= 1.0;
177
			}
178
			if (ev.keyCode == 83) {
179
				camera.position.z += 1.0;
180
			}
181
		});
182 182
	</script>
183 183
</body>
184 184
</html>