addEventListener, event names, the event object, a first look at bubbling.| You do | You see |
|---|---|
| Click a building | It turns gold, HUD shows its name (same as midterm) |
| Double-click the Cafe (it has a door) | You are inside · badge says Inside: Cafe |
| Move the mouse | You look around the room |
| Click a table | HUD names the prop |
| Press Esc | Back on the island · badge says Island |
| Double-click the Church → click Exit building | Different room · same way out |
Camera orbits · hover highlights · click selects · R reset · B night
dblclick a door → enterInterior()
Mouse looks around · click names a prop · R/B do nothing
Esc or Exit button → exitInterior()
let because the value changes when you enter and leave'inside') reads like English — if (mode === 'inside')mode first, then decides what to do| Fire (event) | Listen (main.js) | Handle (events.js) | World state |
|---|---|---|---|
dblclick a building with a door | canvas 'dblclick' | enterInterior(building) | mode = 'inside' |
keydown Escape | window 'keydown' | exitInterior() | mode = 'island' |
click Exit button | #exit-btn 'click' | exitInterior() | mode = 'island' |
| Handler | On the island | Inside a building |
|---|---|---|
onClick | select + show name | name the prop you clicked |
onDoubleClick | enter if it has a door, else details | does nothing |
onKeyDown | R reset · B night | only Esc works |
animate() | orbit + hover | look around with the mouse |
onMouseMove | same both ways — it only records where the mouse is | |
returnonClick → the Cafe gets selected (gold)dblclick runs onDoubleClick → enterInterior()enterInterior cleans up that selection before you go inindex-interior.html is not "entering". It reloads the page and skips every event.mode?enterInterior() while already inside?onMouseMove need to check mode?