Skip to content

Report a pc-joint entity reference that does not resolve - #425

Merged
willeastcott merged 1 commit into
mainfrom
joint-reference-warnings
Aug 29, 2026
Merged

Report a pc-joint entity reference that does not resolve#425
willeastcott merged 1 commit into
mainfrom
joint-reference-warnings

Conversation

@willeastcott

Copy link
Copy Markdown
Contributor

Fixes #389

An entity-a or entity-b that names nothing live produced no constraint and no message, so the joint simply did nothing — indistinguishable from a physics problem, and the failure most likely to bite when referencing a pc-node, whose entity does not exist until its container asset has loaded. The silence was deliberate and pinned by a test; this replaces it, because every neighboring element already reports the same class of mistake loudly: pc-model warns for an asset id that resolves to nothing, and pc-node warns for a name it cannot find, down to offering the closest match.

This is option (1) from the issue: warn on a non-empty reference that does not resolve, with no timing change and nothing breaking.

What warns, and how

The two failures report differently, because they have different fixes:

  • Nothing in the document matches the reference — usually a typo or a missing element:

    pc-joint could not resolve entity-a '#nope' - nothing in the document matches it - constraint not created. Assign entity-a again once the entity exists.

  • Something matches but is not backing an entity — usually timing (a pc-node whose asset has not loaded), or the wrong element entirely:

    pc-joint could not resolve entity-a '#shin' - <pc-node> matches it but is not backing an entity yet - constraint not created. Assign entity-a again once the entity exists.

Telling them apart needs the matched element, so the element lookup is split out of getEntity as findEntityElement (both @internal). getEntity keeps its signature and its silence — what an unresolved reference means depends on the element holding it, so reporting stays with the caller.

What stays silent

An empty reference. On entity-b it is the documented way to pin the first body to a point in world space, and on either attribute it is the transient state of an element whose reference has yet to be assigned. A test pins this.

Scope

pc-joint only — the most punishing of the five reference-resolving elements, because a missing joint has no visual symptom at all. pc-button, pc-scrollbar, pc-scrollview and pc-script are left alone here.

Test plan

  • warns when a reference matches nothing in the document (replaces the test that pinned the silence)
  • warns differently when a reference matches an element backing no entity
  • warns again when a reference is reassigned and still does not resolve
  • stays silent for an empty reference, which is the world-space case
  • Full suite: 996 tests pass across 46 files; lint, type-check and build clean.

🤖 Generated with Claude Code

An entity-a or entity-b that names nothing live produced no constraint and no
message, so the joint simply did nothing - indistinguishable from a physics
problem, and the failure most likely to bite when referencing a pc-node, whose
entity does not exist until its container asset has loaded. The silence was
deliberate and pinned by a test; this replaces it, because every neighboring
element already reports the same class of mistake loudly. pc-model warns for an
asset id that resolves to nothing, and pc-node warns for a name it cannot find,
down to offering the closest match.

An empty reference stays silent. On entity-b it is the documented way to pin the
first body to a point in world space, and on either it is the transient state of
an element whose reference has yet to be assigned.

The two failures report differently, because they have different fixes: nothing
in the document matching the reference is usually a typo, while something
matching that has no entity is usually timing. Telling them apart needs the
matched element, so the element lookup is split out of getEntity as
findEntityElement. getEntity keeps its signature and its silence - what an
unresolved reference means depends on the element holding it, so reporting stays
with the caller. The other four components that resolve references this way are
left alone here.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@willeastcott
willeastcott merged commit 82165d3 into main Aug 29, 2026
3 checks passed
@willeastcott
willeastcott deleted the joint-reference-warnings branch August 29, 2026 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pc-joint silently creates no constraint when entity-a or entity-b does not resolve

1 participant