Update index.html
Browse files- index.html +97 -86
index.html
CHANGED
|
@@ -1,97 +1,108 @@
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
]));
|
| 45 |
-
var islandGeometry = new THREE.ShapeGeometry(new THREE.Shape([
|
| 46 |
-
new THREE.Vector2(-25, -25),
|
| 47 |
-
new THREE.Vector2(-25, 25),
|
| 48 |
-
new THREE.Vector2(25, 25),
|
| 49 |
-
new THREE.Vector2(25, -25)
|
| 50 |
-
]));
|
| 51 |
-
for (var i = 0; i < 3; i++) {
|
| 52 |
-
var fractalShore = new THREE.Mesh(shoreGeometry, material);
|
| 53 |
-
fractalShore.position.set(0, i * 0.02, 0);
|
| 54 |
-
fractalShore.scale.multiplyScalar(1.2 - i * 0.2);
|
| 55 |
-
fractalShore.updateMatrix();
|
| 56 |
-
shoreGeometry.merge(fractalShore.geometry, fractalShore.matrix);
|
| 57 |
-
var fractalIsland = new THREE.Mesh(islandGeometry, material);
|
| 58 |
-
fractalIsland.position.set(0, i * 0.02 + 0.05, 0);
|
| 59 |
-
fractalIsland.scale.multiplyScalar(1.2 - i * 0.2);
|
| 60 |
-
fractalIsland.updateMatrix();
|
| 61 |
-
islandGeometry.merge(fractalIsland.geometry, fractalIsland.matrix);
|
| 62 |
-
}
|
| 63 |
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
});
|
| 70 |
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
|
|
|
| 75 |
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
|
| 81 |
-
|
| 82 |
-
|
|
|
|
|
|
|
| 83 |
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
</body>
|
|
|
|
|
|
| 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 |
+
|
| 106 |
+
</a-scene>
|
| 107 |
</body>
|
| 108 |
+
</html>
|