Update index.html
Browse files- index.html +90 -108
index.html
CHANGED
@@ -1,123 +1,105 @@
|
|
1 |
<!DOCTYPE html>
|
2 |
<html>
|
3 |
<head>
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
</head>
|
13 |
<body>
|
14 |
-
|
15 |
-
|
16 |
-
<img id="sky" src="https://i.imgur.com/1RGMGKj.jpg">
|
17 |
-
</a-assets>
|
18 |
-
<a-entity id="player" position="0 10 0" camera look-controls kinematic-body></a-entity>
|
19 |
-
<a-entity id="iceland" static-body environment="preset:forest;groundYScale:10;groundTexture:https://i.imgur.com/HeYwiie.jpg"></a-entity>
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
mesh.scale.set(voxelSize, voxelSize, voxelSize);
|
37 |
-
mesh.castShadow = true;
|
38 |
-
mesh.receiveShadow = true;
|
39 |
-
mesh.userData['originalPosition'] = mesh.position.clone();
|
40 |
-
mesh.userData['originalRotation'] = mesh.rotation.clone();
|
41 |
-
mesh.userData['id'] = voxelCount++;
|
42 |
-
mesh.name = 'voxel';
|
43 |
-
document.querySelector('#iceland').object3D.add(mesh);
|
44 |
-
}
|
45 |
-
});
|
46 |
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
50 |
|
51 |
-
|
52 |
-
|
|
|
|
|
|
|
53 |
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
});
|
60 |
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
player.setAttribute('velocity', '0 0 0');
|
66 |
-
player.setAttribute('rotation', '0 0 0');
|
67 |
-
}
|
68 |
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
var right = new THREE.Vector3(1, 0, 0);
|
74 |
-
var up = new THREE.Vector3(0, 1, 0);
|
75 |
-
forward.applyQuaternion(camera.object3D.quaternion);
|
76 |
-
right.applyQuaternion(camera.object3D.quaternion);
|
77 |
-
up.applyQuaternion(camera.object3D.quaternion);
|
78 |
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
}
|
84 |
-
if (keys.KeyS) {
|
85 |
-
velocity.sub(forward.clone().multiplyScalar(speed));
|
86 |
-
}
|
87 |
-
if (keys.KeyD) {
|
88 |
-
velocity.add(right.clone().multiplyScalar(speed));
|
89 |
-
}
|
90 |
-
if (keys.KeyA) {
|
91 |
-
velocity.sub(right.clone().multiplyScalar(speed));
|
92 |
-
}
|
93 |
-
if (keys.Space) {
|
94 |
-
velocity.add(up.clone().multiplyScalar(speed));
|
95 |
-
}
|
96 |
-
if (keys.ShiftLeft) {
|
97 |
-
velocity.sub(up.clone().multiplyScalar(speed));
|
98 |
-
}
|
99 |
-
player.setAttribute('velocity', velocity);
|
100 |
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
document.querySelector('[camera]').setAttribute('wasd-flying-controls', '');
|
105 |
-
}
|
106 |
|
107 |
-
|
108 |
-
|
109 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
|
111 |
-
function onKeyUp(event) {
|
112 |
-
keys[event.code] = false;
|
113 |
-
}
|
114 |
-
|
115 |
-
document.addEventListener('keydown', onKeyDown);
|
116 |
-
document.addEventListener('keyup', onKeyUp);
|
117 |
-
|
118 |
-
var keys = {};
|
119 |
-
</script>
|
120 |
-
</a-scene>
|
121 |
-
|
122 |
-
</body>
|
123 |
-
</html>
|
|
|
1 |
<!DOCTYPE html>
|
2 |
<html>
|
3 |
<head>
|
4 |
+
<meta charset="utf-8">
|
5 |
+
<title>Minnesota Map</title>
|
6 |
+
<script src="https://aframe.io/releases/1.2.0/aframe.min.js"></script>
|
7 |
+
<script src="https://unpkg.com/aframe-environment-component/dist/aframe-environment-component.min.js"></script>
|
8 |
+
<script src="https://unpkg.com/@aframe/physics-system"></script>
|
9 |
+
<style>
|
10 |
+
#canvas {
|
11 |
+
height: 500px;
|
12 |
+
width: 800px;
|
13 |
+
}
|
14 |
+
.button {
|
15 |
+
background-color: #222;
|
16 |
+
border: none;
|
17 |
+
color: white;
|
18 |
+
font-size: 16px;
|
19 |
+
padding: 10px 16px;
|
20 |
+
text-align: center;
|
21 |
+
text-decoration: none;
|
22 |
+
display: inline-block;
|
23 |
+
margin: 4px 2px;
|
24 |
+
cursor: pointer;
|
25 |
+
}
|
26 |
+
.link {
|
27 |
+
color: #8CEEEF;
|
28 |
+
}
|
29 |
+
</style>
|
30 |
</head>
|
31 |
<body>
|
32 |
+
<a-scene physics="debug: true;">
|
33 |
+
<a-entity environment="preset: forest"></a-entity>
|
|
|
|
|
|
|
|
|
34 |
|
35 |
+
<!-- Define the polygons for Minnesota -->
|
36 |
+
<a-entity position="0 0 -5">
|
37 |
+
<a-entity position="-2.5 0 0">
|
38 |
+
<a-polygon fill="#2D6C4E" vertices="0 0, 1 0, 0.5 1" static-body></a-polygon>
|
39 |
+
<a-polygon fill="#2D6C4E" vertices="0.5 1, 1 0, 1 1" static-body></a-polygon>
|
40 |
+
<a-polygon fill="#2D6C4E" vertices="0 0, 0 1, 0.5 1" static-body></a-polygon>
|
41 |
+
<a-polygon fill="#2D6C4E" vertices="0.5 0, 1 0, 0.5 1" static-body></a-polygon>
|
42 |
+
</a-entity>
|
43 |
+
<a-entity position="2.5 0 0">
|
44 |
+
<a-polygon fill="#2D6C4E" vertices="0 0, 1 0, 0.5 1" static-body></a-polygon>
|
45 |
+
<a-polygon fill="#2D6C4E" vertices="0 0, 0 1, 0.5 1" static-body></a-polygon>
|
46 |
+
<a-polygon fill="#2D6C4E" vertices="0.5 0, 1 0, 1 1" static-body></a-polygon>
|
47 |
+
<a-polygon fill="#2D6C4E" vertices="0.5 0, 0.5 1, 1 1" static-body></a-polygon>
|
48 |
+
</a-entity>
|
49 |
+
</a-entity>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
+
<!-- Define the camera and buttons -->
|
52 |
+
<a-entity id="player" position="0 50 0" kinematic-body>
|
53 |
+
<a-entity id="camera" camera look-controls kinematic-body></a-entity>
|
54 |
+
<a-entity id="zoomIn" class="button" position="-2.5 0 0" rotation="0 0 180" onclick="zoomIn()">+</a-entity>
|
55 |
+
<a-entity id="zoomOut" class="button" position="2.5 0 0" onclick="zoomOut()">-</a-entity>
|
56 |
+
</a-entity>
|
57 |
|
58 |
+
<!-- Define the script to update the video texture -->
|
59 |
+
<script>
|
60 |
+
const video = document.querySelector('#video');
|
61 |
+
const canvas = document.querySelector('#videoTextureCanvas');
|
62 |
+
const ctx = canvas.getContext('2d');
|
63 |
|
64 |
+
function updateVideoTexture() {
|
65 |
+
ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
|
66 |
+
const texture = document.querySelector('#videoTexture');
|
67 |
+
texture.needsUpdate = true;
|
68 |
+
}
|
|
|
69 |
|
70 |
+
video.addEventListener('play', function() {
|
71 |
+
setInterval(updateVideoTexture, 16);
|
72 |
+
});
|
73 |
+
</script>
|
|
|
|
|
|
|
74 |
|
75 |
+
<script>
|
76 |
+
// Get the camera entity
|
77 |
+
const player = document.querySelector('#player');
|
78 |
+
const camera = document.querySelector('#camera');
|
|
|
|
|
|
|
|
|
|
|
79 |
|
80 |
+
// Define the zoom in and zoom out functions
|
81 |
+
function zoomIn() {
|
82 |
+
camera.setAttribute('position', {x: camera.getAttribute('position').x, y: camera.getAttribute('position').y - 5, z: camera.getAttribute('position').z});
|
83 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
|
85 |
+
function zoomOut() {
|
86 |
+
camera.setAttribute('position', {x: camera.getAttribute('position').x, y: camera.getAttribute('position').y + 5, z: camera.getAttribute('position').z});
|
87 |
+
}
|
|
|
|
|
88 |
|
89 |
+
// Define the gravity and physics for the player
|
90 |
+
player.addEventListener('componentinitialized', function (evt) {
|
91 |
+
if (evt.detail.name !== 'kinematic-body') { return; }
|
92 |
+
const physics = player.getAttribute('physics');
|
93 |
+
physics.debug = false;
|
94 |
+
physics.driver = 'physics';
|
95 |
+
physics.debug = true;
|
96 |
+
physics.debugInterval = 500;
|
97 |
+
physics.debugTiming = 'interval';
|
98 |
+
player.setAttribute('physics', physics);
|
99 |
+
player.body.linearDamping = 0.9;
|
100 |
+
player.body.angularDamping = 0.9;
|
101 |
+
player.body.gravity.y = -30;
|
102 |
+
player.body.mass = 80;
|
103 |
+
});
|
104 |
+
</script>
|
105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|