awacke1 commited on
Commit
236dd8c
·
1 Parent(s): 71832f9

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +97 -86
index.html CHANGED
@@ -1,97 +1,108 @@
1
  <!DOCTYPE html>
2
  <html>
3
- <head>
4
- <meta charset="utf-8">
5
- <title>Iceland Landscape</title>
6
- <style>
7
- body {
8
- margin: 0;
9
- overflow: hidden;
10
- }
11
- canvas {
12
- width: 100%;
13
- height: 100%;
14
- }
15
- </style>
16
- </head>
17
- <body>
18
- <canvas id="myCanvas"></canvas>
19
- <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
20
- <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/examples/js/controls/OrbitControls.js"></script>
21
- <script>
22
- // Load Iceland topography data
23
- var loader = new THREE.TerrainLoader();
24
- loader.load('iceland-heightmap.png', function(terrainData) { // Initialize the scene, camera, and renderer
25
- var scene = new THREE.Scene();
26
- var camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
27
- var renderer = new THREE.WebGLRenderer({ antialias: true });
28
- renderer.setSize(window.innerWidth, window.innerHeight);
29
- document.body.appendChild(renderer.domElement);
 
 
 
 
30
 
31
- // Create landscape mesh
32
- var geometry = new THREE.PlaneGeometry(100, 100, terrainData.width - 1, terrainData.height - 1);
33
- geometry.rotateX(-Math.PI / 2);
34
- for (var i = 0, l = geometry.vertices.length; i < l; i++) {
35
- geometry.vertices[i].z = terrainData.heightmap[i] / 100;
36
- }
 
 
 
 
 
 
 
 
 
37
 
38
- // Create fractal seashore and island
39
- var shoreGeometry = new THREE.ShapeGeometry(new THREE.Shape([
40
- new THREE.Vector2(-50, -50),
41
- new THREE.Vector2(-50, 50),
42
- new THREE.Vector2(50, 50),
43
- new THREE.Vector2(50, -50)
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
- // Create material for the landscape
65
- var material = new THREE.MeshStandardMaterial({
66
- color: 0xaaaaaa,
67
- metalness: 0.1,
68
- roughness: 0.7
69
- });
70
 
71
- // Combine landscape and fractal seashore and island meshes
72
- var landscape = new THREE.Mesh(geometry, material);
73
- landscape.geometry.merge(islandGeometry);
74
- scene.add(landscape);
 
75
 
76
- // Add point light to scene
77
- var light = new THREE.PointLight(0xffffff, 1, 100);
78
- light.position.set(0, 10, 0);
79
- scene.add(light);
80
 
81
- // Set camera position
82
- camera.position.set(0, 10, 20);
 
 
83
 
84
- // Add orbit controls for camera
85
- var controls = new THREE.OrbitControls(camera, renderer.domElement);
86
- controls.target.set(0, 10, 0);
87
- controls.update();
88
 
89
- // Render the scene
90
- function animate() {
91
- requestAnimationFrame(animate);
92
- renderer.render(scene, camera);
93
- }
94
- animate();
95
- });
96
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>