refactor(events)!: empty-space clicks via canvas event.object — removing *Missed#76
Draft
bigmistqke wants to merge 2 commits into
Draft
refactor(events)!: empty-space clicks via canvas event.object — removing *Missed#76bigmistqke wants to merge 2 commits into
bigmistqke wants to merge 2 commits into
Conversation
A void — a gesture that hit no object — is read from the canvas-level handler: the canvas always receives the event (unless a handler stopped it), with `event.object` undefined when the ray hit nothing. Removes the `onClickMissed` / `onDoubleClickMissed` / `onContextMenuMissed` handlers. `click()` now delegates to the shared `propagate()` path that `onPointerDown` / `onPointerUp` / `onPointerMove` / `onWheel` already use, so every discrete gesture has one dispatch path and one void model. `PointerRaycaster.intersectObject`, used only by the dropped re-raycast phase, is removed from the type. Canvas-level handlers type `event.object` as `Object3D | undefined` — object-level handlers keep `Object3D`, since they only fire on a hit — so `if (!event.object)` type-checks as the empty-space test. Tests assert the canvas handler fires with `event.object` undefined on a miss and set to the hit object on a hit, across all seven gestures.
Replace the *Missed material with "Clicking empty space": a canvas-level handler receives every gesture, and `event.object` is undefined when the ray hit nothing — read `if (!event.object)`. Updates the tour chapter, the events reference, and the Canvas props; the glossary's "Missed event" entry becomes "Void". Rename the demo snippet to 04-void-click.tsx and switch it to `onClick` with an `event.object` check.
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Alternative to #75. Where #75 adds a positive
onVoid*family, this removes the*Missedhandlers and leans on a single canvas-level check:event.object.Summary
To react to a gesture that hit nothing, put the handler on the
<Canvas>and readevent.object— the nearest hit object, orundefinedwhen the ray hit empty space.This drops
onClickMissed/onDoubleClickMissed/onContextMenuMissed.Semantics
stopPropagation().event.objectis the nearest hit, orundefinedon empty space.onClick,onDoubleClick,onContextMenu,onPointerDown,onPointerUp,onPointerMove,onWheel— all sharing one dispatch path (propagate()).click()folds into that path; the bespoke missed-tracking phases it used are gone.onPointerEnter/onPointerLeaveare unaffected: they mark the canvas boundary (enter on entry, leave on exit), not a per-event hit, so there's no empty-vs-hit distinction to read there.stopPropagation()— never reaches the canvas, so it's neither a hit nor an empty click at that level.Removed: per-object
*Missed*Missedalso fired on individual objects ("the gesture didn't reach me, specifically"), and a total miss fired both the canvas handler andonClickMissedfor the same empty click. That per-object inversion is gone; the canvasevent.objectcheck covers empty space directly.Types
Canvas-level handlers type
event.objectasObject3D | undefined, soif (!event.object)type-checks as the empty-space test. Object-level handlers keepobject: Object3D, since they only fire on a hit.Tests
The canvas handler is asserted to fire with
event.objectundefined on a miss and set to the hit object on a hit, across all seven gestures.Docs
Tour chapter, events reference, Canvas props, and the
CONTEXT.mdglossary migrated to theevent.objectpattern; the demo snippet renamed accordingly.