feat: implement keyboard-driven car simulation game#11
feat: implement keyboard-driven car simulation game#11novo3d-open-swe[bot] wants to merge 17 commits into
Conversation
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. Comment |
There was a problem hiding this comment.
This PR is being reviewed by Cursor Bugbot
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
| const wheelRotation = speed * deltaTime * 2 | ||
| this.wheels.forEach(wheel => { | ||
| wheel.rotation.x += wheelRotation | ||
| }) |
There was a problem hiding this comment.
Wheel rotation ignores reverse movement direction
Medium Severity
The wheel rotation calculation uses speed (velocity magnitude), which is always positive. When the car reverses, wheels visually spin forward instead of backward. The rotation direction needs to account for whether the car is moving forward or backward relative to its facing direction, but currently wheelRotation is always added regardless of movement direction.
| // Clamp to max speed | ||
| if (speed > this.maxSpeed) { | ||
| this.velocity.normalize().multiplyScalar(this.maxSpeed) | ||
| } |
There was a problem hiding this comment.
Stale speed value used after friction modifies velocity
Low Severity
The speed variable is calculated at line 133 before friction is applied, but then used at lines 141, 146, and 148 after friction has modified this.velocity. The max speed clamping check and turn calculations use stale pre-friction values. This can cause the max speed clamp to override friction effects, making the car slightly faster than it should be after friction is applied.
Additional Locations (1)
- Remove incorrect return statement from Camera constructor that was returning the raw THREE.PerspectiveCamera instead of the wrapper class - Update Animate.js and Main.js to access camera.camera for rendering - Swap left/right turn direction values in KeyboardControls to fix inverted steering
Fixes #10
Overview
This pull request implements a complete keyboard-driven car simulation game using Three.js. The game features a drivable car with realistic physics, a detailed game environment, and a third-person follow camera.
Key Features
Car System
src/Main/Car.js): Fully functional vehicle with:Game Environment
src/Main/Environment.js): Complete game world with:Input System
src/Main/KeyboardControls.js): Responsive keyboard input handling:Camera System
User Interface
Technical Changes
Modified Files
src/Main/Main.js: Wired up all components, removed OrbitControlssrc/Main/Geometry.js: Replaced red cube with Car and Environment instancessrc/Main/Camera.js: Implemented third-person follow camera with smooth interpolationsrc/Main/Controls.js: Replaced OrbitControls with KeyboardControlssrc/Main/Animate.js: Added car physics and camera updates to animation loopsrc/Main/Utils/Helpers.js: Removed debug helpers (AxesHelper, GridHelper)src/style.css: Added HUD styling, removed unused .label classsrc/index.html: Added HUD elements for speed display and controlsNew Files
src/Main/Car.js: Complete car simulation with physicssrc/Main/Environment.js: Game world generationsrc/Main/KeyboardControls.js: Keyboard input managementPhysics Implementation
Visual Enhancements
Note
Builds a playable car demo with physics, input, camera follow, and on-screen HUD.
Car(physics: acceleration/brake/friction/turning, wheel rotation) and speed HUD updatesEnvironment(200x200 ground with grid, sky/fog, boundary walls, cones/boxes/pillars)KeyboardControlsand switchControlsto use it (replaces OrbitControls)Camerato third-person follower withupdate(offset, look-ahead, lerp); render viacamera.cameraAnimateloop to callcar.update(...)andcamera.update(...)Geometryto instantiateEnvironmentandCar; simplifyHelpersindex.htmland styling instyle.csscamera.cameraWritten by Cursor Bugbot for commit 2a93b31. This will update automatically on new commits. Configure here.