Spaces:
Running
Running
Update index.html
Browse files- index.html +262 -23
index.html
CHANGED
@@ -1,29 +1,268 @@
|
|
1 |
<!DOCTYPE html>
|
2 |
-
<html
|
3 |
-
|
4 |
<head>
|
5 |
-
<
|
6 |
-
<
|
7 |
-
|
8 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
9 |
-
<title>Transformers.js - Object Detection</title>
|
10 |
</head>
|
11 |
-
|
12 |
<body>
|
13 |
-
<
|
14 |
-
|
15 |
-
<
|
16 |
-
<
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
</html>
|
|
|
1 |
<!DOCTYPE html>
|
2 |
+
<html>
|
|
|
3 |
<head>
|
4 |
+
<title>3D Tile Driving Game</title>
|
5 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/aframe/1.4.2/aframe.min.js"></script>
|
|
|
|
|
|
|
6 |
</head>
|
|
|
7 |
<body>
|
8 |
+
<a-scene>
|
9 |
+
<!-- Assets -->
|
10 |
+
<a-assets>
|
11 |
+
<img id="ground-tile" src="/api/placeholder/128/128" />
|
12 |
+
<img id="bump-map" src="/api/placeholder/128/128" />
|
13 |
+
|
14 |
+
<!-- Custom SVG shapes -->
|
15 |
+
<svg id="crystal" viewBox="0 0 100 100">
|
16 |
+
<path d="M50 0 L100 25 L100 75 L50 100 L0 75 L0 25 Z" fill="#88ff88"/>
|
17 |
+
</svg>
|
18 |
+
|
19 |
+
<svg id="starShape" viewBox="0 0 100 100">
|
20 |
+
<path d="M50 0 L63 38 L100 38 L69 59 L81 100 L50 75 L19 100 L31 59 L0 38 L37 38 Z" fill="#ffff00"/>
|
21 |
+
</svg>
|
22 |
+
|
23 |
+
<svg id="pyramid" viewBox="0 0 100 100">
|
24 |
+
<path d="M50 0 L100 100 L0 100 Z" fill="#ff88ff"/>
|
25 |
+
</svg>
|
26 |
+
</a-assets>
|
27 |
+
|
28 |
+
<!-- Environment -->
|
29 |
+
<a-sky color="#001133"></a-sky>
|
30 |
+
<a-entity id="tileMap"></a-entity>
|
31 |
+
|
32 |
+
<!-- Decorative 3D Shapes -->
|
33 |
+
<a-entity id="decorativeShapes"></a-entity>
|
34 |
+
|
35 |
+
<!-- Player Character -->
|
36 |
+
<a-entity id="player" position="2 0 2">
|
37 |
+
<!-- Player body -->
|
38 |
+
<a-sphere radius="0.3" color="#44aaff"></a-sphere>
|
39 |
+
<!-- Player head -->
|
40 |
+
<a-sphere radius="0.2" position="0 0.4 0" color="#4488ff"></a-sphere>
|
41 |
+
<!-- Arms -->
|
42 |
+
<a-cylinder radius="0.08" height="0.5" position="0.3 0.1 0" rotation="0 0 90" color="#4488ff"></a-cylinder>
|
43 |
+
<a-cylinder radius="0.08" height="0.5" position="-0.3 0.1 0" rotation="0 0 90" color="#4488ff"></a-cylinder>
|
44 |
+
</a-entity>
|
45 |
+
|
46 |
+
<!-- Car -->
|
47 |
+
<a-entity id="car" position="0 0.5 0">
|
48 |
+
<!-- Car body with gradient color -->
|
49 |
+
<a-box width="2" height="0.75" depth="4" color="#ff3333" metalness="0.8" roughness="0.2" shadow></a-box>
|
50 |
+
<!-- Car roof -->
|
51 |
+
<a-box width="1.5" height="0.75" depth="2" position="0 0.75 -0.5" color="#cc2222" metalness="0.8" roughness="0.2" shadow></a-box>
|
52 |
+
<!-- Wheels with chrome effect -->
|
53 |
+
<a-cylinder radius="0.4" height="0.3" rotation="0 0 90" position="1 -0.3 1" color="#333333" metalness="0.9" roughness="0.1"></a-cylinder>
|
54 |
+
<a-cylinder radius="0.4" height="0.3" rotation="0 0 90" position="-1 -0.3 1" color="#333333" metalness="0.9" roughness="0.1"></a-cylinder>
|
55 |
+
<a-cylinder radius="0.4" height="0.3" rotation="0 0 90" position="1 -0.3 -1" color="#333333" metalness="0.9" roughness="0.1"></a-cylinder>
|
56 |
+
<a-cylinder radius="0.4" height="0.3" rotation="0 0 90" position="-1 -0.3 -1" color="#333333" metalness="0.9" roughness="0.1"></a-cylinder>
|
57 |
+
<!-- Headlights -->
|
58 |
+
<a-sphere radius="0.2" position="0.8 0 1.8" color="#ffff88" emission="intensity: 0.5"></a-sphere>
|
59 |
+
<a-sphere radius="0.2" position="-0.8 0 1.8" color="#ffff88" emission="intensity: 0.5"></a-sphere>
|
60 |
+
</a-entity>
|
61 |
+
|
62 |
+
<!-- Camera -->
|
63 |
+
<a-entity id="rig" position="0 2 8">
|
64 |
+
<a-camera look-controls wasd-controls="enabled: false"></a-camera>
|
65 |
+
</a-entity>
|
66 |
+
|
67 |
+
<!-- Lighting -->
|
68 |
+
<a-light type="ambient" color="#445566"></a-light>
|
69 |
+
<a-light type="directional" position="2 4 1" color="#ffffff" intensity="0.8" cast-shadow="true"></a-light>
|
70 |
+
</a-scene>
|
71 |
+
|
72 |
+
<script>
|
73 |
+
// Car physics parameters
|
74 |
+
const carState = {
|
75 |
+
position: { x: 0, z: 0 },
|
76 |
+
rotation: 0,
|
77 |
+
velocity: 0,
|
78 |
+
acceleration: 0,
|
79 |
+
maxSpeed: 0.2,
|
80 |
+
turnSpeed: 2,
|
81 |
+
friction: 0.98
|
82 |
+
};
|
83 |
+
|
84 |
+
// Player state
|
85 |
+
const playerState = {
|
86 |
+
position: { x: 2, y: 0, z: 2 },
|
87 |
+
velocity: { x: 0, y: 0, z: 0 },
|
88 |
+
speed: 0.1,
|
89 |
+
jumpForce: 0.2,
|
90 |
+
isJumping: false
|
91 |
+
};
|
92 |
+
|
93 |
+
// Generate tile map with varying colors
|
94 |
+
const tileMap = document.querySelector('#tileMap');
|
95 |
+
const mapSize = 20;
|
96 |
+
const tileSize = 5;
|
97 |
+
|
98 |
+
const colors = ['#2244aa', '#22aa44', '#aa2244', '#aaaa22'];
|
99 |
+
|
100 |
+
for (let x = 0; x < mapSize; x++) {
|
101 |
+
for (let z = 0; z < mapSize; z++) {
|
102 |
+
const tile = document.createElement('a-box');
|
103 |
+
tile.setAttribute('width', tileSize);
|
104 |
+
tile.setAttribute('height', 0.1);
|
105 |
+
tile.setAttribute('depth', tileSize);
|
106 |
+
tile.setAttribute('position', {
|
107 |
+
x: x * tileSize - (mapSize * tileSize) / 2,
|
108 |
+
y: -0.05,
|
109 |
+
z: z * tileSize - (mapSize * tileSize) / 2
|
110 |
+
});
|
111 |
+
tile.setAttribute('material', {
|
112 |
+
color: colors[(x + z) % colors.length],
|
113 |
+
src: '#ground-tile',
|
114 |
+
repeat: { x: 1, y: 1 },
|
115 |
+
normalMap: '#bump-map'
|
116 |
+
});
|
117 |
+
tile.setAttribute('shadow', '');
|
118 |
+
tileMap.appendChild(tile);
|
119 |
+
}
|
120 |
+
}
|
121 |
+
|
122 |
+
// Generate decorative shapes
|
123 |
+
const shapes = document.querySelector('#decorativeShapes');
|
124 |
+
const numShapes = 30;
|
125 |
+
|
126 |
+
for (let i = 0; i < numShapes; i++) {
|
127 |
+
const shape = document.createElement('a-entity');
|
128 |
+
const type = Math.floor(Math.random() * 3);
|
129 |
+
const scale = 2 + Math.random() * 3;
|
130 |
+
const x = (Math.random() - 0.5) * mapSize * tileSize;
|
131 |
+
const z = (Math.random() - 0.5) * mapSize * tileSize;
|
132 |
+
const rotY = Math.random() * 360;
|
133 |
+
|
134 |
+
shape.setAttribute('position', `${x} ${scale/2} ${z}`);
|
135 |
+
shape.setAttribute('rotation', `0 ${rotY} 0`);
|
136 |
+
shape.setAttribute('scale', `${scale} ${scale} ${scale}`);
|
137 |
|
138 |
+
switch(type) {
|
139 |
+
case 0:
|
140 |
+
shape.setAttribute('geometry', 'primitive: cylinder; radius: 0.5; height: 1;');
|
141 |
+
shape.setAttribute('material', 'color: #ff88ff; metalness: 0.5; roughness: 0.2');
|
142 |
+
break;
|
143 |
+
case 1:
|
144 |
+
shape.setAttribute('geometry', 'primitive: box; width: 1; height: 1; depth: 1;');
|
145 |
+
shape.setAttribute('material', 'color: #88ffff; metalness: 0.5; roughness: 0.2');
|
146 |
+
break;
|
147 |
+
case 2:
|
148 |
+
shape.setAttribute('geometry', 'primitive: cone; radiusBottom: 0.7; radiusTop: 0;');
|
149 |
+
shape.setAttribute('material', 'color: #ffff88; metalness: 0.5; roughness: 0.2');
|
150 |
+
break;
|
151 |
+
}
|
152 |
+
|
153 |
+
shapes.appendChild(shape);
|
154 |
+
}
|
155 |
+
|
156 |
+
// Controls
|
157 |
+
const car = document.querySelector('#car');
|
158 |
+
const player = document.querySelector('#player');
|
159 |
+
const camera = document.querySelector('#rig');
|
160 |
+
let keys = {};
|
161 |
+
|
162 |
+
document.addEventListener('keydown', (e) => {
|
163 |
+
keys[e.key.toLowerCase()] = true;
|
164 |
+
});
|
165 |
+
|
166 |
+
document.addEventListener('keyup', (e) => {
|
167 |
+
keys[e.key.toLowerCase()] = false;
|
168 |
+
});
|
169 |
+
|
170 |
+
// Game loop
|
171 |
+
function updateGame() {
|
172 |
+
// Car controls
|
173 |
+
if (keys['w']) {
|
174 |
+
carState.acceleration = 0.001;
|
175 |
+
} else if (keys['s']) {
|
176 |
+
carState.acceleration = 0;
|
177 |
+
carState.velocity *= 0.9;
|
178 |
+
} else if (keys['x']) {
|
179 |
+
carState.acceleration = -0.001;
|
180 |
+
} else {
|
181 |
+
carState.acceleration = 0;
|
182 |
+
}
|
183 |
+
|
184 |
+
if (keys['a']) {
|
185 |
+
carState.rotation += carState.turnSpeed * Math.abs(carState.velocity);
|
186 |
+
}
|
187 |
+
if (keys['d']) {
|
188 |
+
carState.rotation -= carState.turnSpeed * Math.abs(carState.velocity);
|
189 |
+
}
|
190 |
+
|
191 |
+
// Player controls (IJKL + Space)
|
192 |
+
if (keys['i']) {
|
193 |
+
playerState.position.z -= playerState.speed;
|
194 |
+
}
|
195 |
+
if (keys['k']) {
|
196 |
+
playerState.position.z += playerState.speed;
|
197 |
+
}
|
198 |
+
if (keys['j']) {
|
199 |
+
playerState.position.x -= playerState.speed;
|
200 |
+
}
|
201 |
+
if (keys['l']) {
|
202 |
+
playerState.position.x += playerState.speed;
|
203 |
+
}
|
204 |
+
if (keys[' '] && !playerState.isJumping) {
|
205 |
+
playerState.velocity.y = playerState.jumpForce;
|
206 |
+
playerState.isJumping = true;
|
207 |
+
}
|
208 |
+
|
209 |
+
// Player physics
|
210 |
+
playerState.velocity.y -= 0.01; // Gravity
|
211 |
+
playerState.position.y += playerState.velocity.y;
|
212 |
+
|
213 |
+
// Ground collision
|
214 |
+
if (playerState.position.y < 0) {
|
215 |
+
playerState.position.y = 0;
|
216 |
+
playerState.velocity.y = 0;
|
217 |
+
playerState.isJumping = false;
|
218 |
+
}
|
219 |
+
|
220 |
+
// Update car physics
|
221 |
+
carState.velocity += carState.acceleration;
|
222 |
+
carState.velocity *= carState.friction;
|
223 |
+
carState.velocity = Math.max(Math.min(carState.velocity, carState.maxSpeed), -carState.maxSpeed);
|
224 |
+
|
225 |
+
const rad = (carState.rotation * Math.PI) / 180;
|
226 |
+
carState.position.x += Math.sin(rad) * carState.velocity;
|
227 |
+
carState.position.z += Math.cos(rad) * carState.velocity;
|
228 |
+
|
229 |
+
// Update positions
|
230 |
+
car.setAttribute('position', {
|
231 |
+
x: carState.position.x,
|
232 |
+
y: 0.5,
|
233 |
+
z: carState.position.z
|
234 |
+
});
|
235 |
+
car.setAttribute('rotation', {
|
236 |
+
x: 0,
|
237 |
+
y: carState.rotation,
|
238 |
+
z: 0
|
239 |
+
});
|
240 |
+
|
241 |
+
player.setAttribute('position', {
|
242 |
+
x: playerState.position.x,
|
243 |
+
y: playerState.position.y + 0.5,
|
244 |
+
z: playerState.position.z
|
245 |
+
});
|
246 |
+
|
247 |
+
// Camera follows car
|
248 |
+
const cameraDistance = 8;
|
249 |
+
const cameraHeight = 2;
|
250 |
+
camera.setAttribute('position', {
|
251 |
+
x: carState.position.x - Math.sin(rad) * cameraDistance,
|
252 |
+
y: cameraHeight,
|
253 |
+
z: carState.position.z - Math.cos(rad) * cameraDistance
|
254 |
+
});
|
255 |
+
camera.setAttribute('rotation', {
|
256 |
+
x: 15,
|
257 |
+
y: carState.rotation,
|
258 |
+
z: 0
|
259 |
+
});
|
260 |
+
|
261 |
+
requestAnimationFrame(updateGame);
|
262 |
+
}
|
263 |
+
|
264 |
+
// Start the game loop
|
265 |
+
updateGame();
|
266 |
+
</script>
|
267 |
+
</body>
|
268 |
</html>
|