Inspiration
Many people in Japan now learn to fly drones for work, from inspections to farming and filming, and there is a national drone pilot license. Beginners mostly struggle with stick coordination: which stick does what, how to hold altitude, and how to fly with the nose pointing at you. A simulator can measure all of that, but numbers alone don't tell a beginner what to practice next.
A good instructor looks at one flight and says "you pushed throttle the wrong way twice, slow down near the pad, try Lesson 12 next". We wanted that instructor inside the simulator, running privately on the learner's own PC whenever possible.
What it does
- Training game. A 3D drone-flight game with 20 step-by-step practice lessons (takeoff, hovering, pitch / roll / yaw, square, circle, figure-eight, nose-in, gates, slalom, obstacles, tunnel, precision landing, FPV, final challenge) and races. It supports Mode 1 / Mode 2 stick layouts on touch, keyboard or gamepad.
- Flight measurement. After every lesson or race, the game measures the flight:
- control accuracy, altitude stability, time against target, collisions, smoothness
- landing accuracy and wrong-direction stick inputs per axis
- for races: lap times, rank and medal targets
- AI Flight Coach. One button sends only these numbers to Firebase AI Logic. The AI returns structured coaching in English or Japanese: a summary, strengths, improvements, stick-technique advice, a measurable next goal and a recommended lesson.
- Recommended lesson. The recommendation is validated against the real lesson list (L01–L20) and becomes a one-tap "Start this lesson" button. If the model suggests an invalid lesson, the game falls back to its own weak-skill analysis and says so.
- Honest display. The UI keeps measured data and AI-generated text visually separate. It shows which engine wrote the text, On-device AI or Cloud AI, taken directly from the SDK's
response.inferenceSource. - AI menu. Shows the status (on-device / cloud / downloading / unavailable / offline / error) and lets you choose AUTO / ON-DEVICE / CLOUD. It can prepare the on-device model and shows usage counters and a privacy explanation.
How we built it
- Base game. A custom WebGL2 engine in TypeScript bundled with esbuild, with no game framework. All 3D models, sound and music are generated procedurally in code.
- Firebase AI Logic. Setup is
getAI(app, { backend: new GoogleAIBackend() })plusgetGenerativeModel(ai, { mode, onDeviceParams, inCloudParams }). The three modes are:- AUTO =
PREFER_ON_DEVICE(Gemini Nano in Chrome, with cloud fallback) - ON-DEVICE =
ONLY_ON_DEVICE(private; works offline once the model is downloaded) - CLOUD =
ONLY_IN_CLOUD(gemini-3.5-flash-lite, Gemini Developer API free tier)
- AUTO =
- On-device setup.
onDeviceParams.createOptions.expectedInputs/Outputsdeclares the language (en / ja).- The on-device path gets a JSON-schema
promptOptions.responseConstraintfor structured output. initializeDeviceModel()is triggered from a user gesture in the AI menu.
- App Check. Fraud Defense (formerly reCAPTCHA Enterprise) on the hosted site, with enforcement on for Firebase AI Logic; the debug provider is used only on localhost.
- Cost safety on the free tier.
- AI calls happen only on button press, never per frame or automatically.
- An in-flight lock prevents duplicates, followed by a 20-second cooldown and a daily cloud cap.
- Cloud AI pauses automatically on quota errors; AUTO then tries on-device only.
- The game is always fully playable without AI.
- Small footprint. The Firebase JS SDK 13.4.0 is loaded lazily from the official CDN, so players who never use AI download nothing extra.
Challenges we ran into
- SDK detail. In hybrid mode, passing
inCloudParamswithoutinCloudParams.modelthrowsAI/no-model, because the default model applies only wheninCloudParamsis omitted. We now always setgemini-3.5-flash-liteexplicitly. - Trustworthy output from a small model. Gemini Nano sometimes returned almost-JSON, for example with unescaped quotes or
"0"as a lesson ID. We added:- a JSON-schema
responseConstrainton the on-device path - a tolerant field-by-field parser
- lesson-ID normalization and validation, so no invalid button is ever shown
- a JSON-schema
- Honest inference-path display. We show On-device or Cloud only when
inferenceSource(on_device/in_cloud) says so, never by guessing from the selected mode. - Age and safety. The original game is used in an elementary-school workshop, but the Gemini API terms require users to be 18+. We built a completely separate adults-only edition:
- its own URL and save keys, and no link from the children's version
noindex/ robots /X-Robots-Tag- an 18+ confirmation plus an access code; the game bundle is AES-256-GCM encrypted with a key derived from that code, so it cannot be loaded without it
The children's version contains no generative AI and was not modified.
- App Check provider. reCAPTCHA Classic (v3) can no longer be newly registered in Firebase App Check, so production uses Fraud Defense (reCAPTCHA Enterprise).
Accomplishments that we're proud of
- A real hybrid-AI feature that turns raw flight telemetry into concrete coaching and a next lesson inside the game loop. It isn't a chat box bolted onto a game.
- The same UX on-device and in the cloud, with the actual engine shown for every answer.
- Verified on Windows desktop Chrome (Gemini Nano downloaded) with the Firebase Spark (no-cost) plan, on the hosted build:
| Mode | Engine (inferenceSource) |
Time |
|---|---|---|
| CLOUD | in_cloud |
≈ 1.7–3.1 s |
| ON-DEVICE | on_device |
≈ 9–32 s |
| AUTO | on_device on Chrome with Gemini Nano; in_cloud fallback on a browser without it |
— |
- English and Japanese UI for the main flow and all 20 lessons.
What we learned
On-device models shine for short, structured, private tasks like "review this one flight", but they need guard rails: schemas, validation and fallbacks. Hybrid inference lets the same feature reach machines without Gemini Nano with no code duplication.
What's next
- AI-generated personalized drills (custom waypoint courses) from the weakest metric
- A multi-session progress summary
- A safety and regulations Q&A grounded in the quiz content
- Mobile builds
Project history (transparency)
The base 3D drone-flight game (custom WebGL2 engine, 20 lessons, races, exploration, quiz) was built by the same creator starting Nov 26, 2026, first as a Japanese drone-learning game for a children's workshop. That children's trial version is a separate product with no generative AI and was not changed.
Built for this hackathon (Nov 30 – Dec 1, 2026), on top of that game:
- all Firebase AI Logic integration: hybrid inference with AUTO / ON-DEVICE / CLOUD,
inferenceSourcedisplay, App Check, quotas, cooldown and error handling - flight-report extraction from practice and race results
- the AI Flight Coach UI and AI menu
- structured coaching with a validated, one-tap recommended lesson
- the adults-only encrypted access gate, separate save keys and separate build/hosting
- the English UI for the main flow and the English text for all 20 lessons
Try it
- Hosted (adults 18+, access code in the judges' testing instructions): https://drone-sky-racing-ai-coach.pages.dev
- Source (Apache-2.0): https://github.com/takkaspringer/drone-sky-racing-ai-flight-coach
Created by 美味しい果糖 (Kato).