Build a complete 3D arcade racing game in a SINGLE self-cont...
Prompt
Build a complete 3D arcade racing game in a SINGLE self-contained HTML file. Use Three.js loaded through an import map from a CDN (pin a specific version). No other libraries, no physics engine, and no external models, textures, or sound files: all geometry is built in code and all audio is synthesized with Web Audio. TRACK - Generate a closed-loop track from a numeric seed, using your own seeded PRNG (not Math.random) and a Catmull-Rom spline. Show the seed on the title screen; the same seed must always produce the same track. - The track has hills (elevation changes) and banked corners. Bank angle scales with how sharp the corner is. - The track must NEVER intersect or overlap itself. Detect this and regenerate if it happens. - Barriers line both edges. The road mesh is extruded along the spline with correct normals, with no twisting or flipping. CAR PHYSICS (write your own, fixed 60 Hz timestep) - Acceleration, braking, reverse, and a top speed. - Steering gets less sharp at high speed. - Holding Space as a handbrake reduces rear grip, so the car drifts. - Barrier collisions make the car slide along the wall and lose speed. The car must never pass through a wall or stop dead. - The car follows hills and banking (pitch and roll), and gets airborne over crests. OPPONENTS - 3 AI cars at different skill levels follow a racing line. They must brake for sharp corners coming up, avoid colliding with each other, and recover after hitting a wall. RACE SYSTEM - 3 laps, with a 3-2-1 countdown, a live position (1stβ4th), lap times, and a results screen. - Invisible checkpoints in order: driving backwards or cutting across the infield must not count as a lap. - Ghost replay: record your best lap and replay it as a see-through car on the following laps. It must match your recorded lap exactly, frame for frame. CAMERA & PRESENTATION - Chase camera with smooth follow. Field of view widens with speed. Press C to switch to a hood camera. - 2D minimap overlay showing the track and all car positions. - Directional sunlight with shadows, a gradient sky, fog, and at least 500 trees or rocks drawn with InstancedMesh. - Skid marks while drifting, and dust particles when driving off the road. - Engine sound whose pitch rises and falls with speed and simulated gear changes. - FPS counter in the corner. Aim for 60 FPS on a normal laptop. Controls: arrow keys or WASD to drive, Space for handbrake, C for camera, R to reset the car onto the track, Esc to pause. Show the controls on the title screen. Output only the complete HTML file. Before the code, write at most 5 sentences explaining how you detect track self-intersection and how the ghost stays in sync.
A system prompt was added to support web rendering
Response not available