Skip to content

The bones were culled against the origin, not the body - #30

Merged
WWStoryMode merged 1 commit into
mainfrom
fix/bones-culled-against-the-origin
Oct 19, 2026
Merged

WWStoryMode merged 1 commit into
mainfrom
fix/bones-culled-against-the-origin

Conversation

@WWStoryMode

Copy link
Copy Markdown
Owner

At some camera angles the amber bones vanished while the joint spheres stayed on screen.

Cause

The bones are one LineSegments whose vertices are rewritten in place every frame. applyFrame sets needsUpdate, which re-uploads them to the GPU and does not touch the bounding sphere. three computes that sphere once, lazily, on its first cull test — and at that moment the buffer is still zero-filled, so it caches centre (0,0,0) radius 0, a point at the world origin, and keeps it for the life of the figure.

The renderer then asks "is the origin in view?" and throws away the whole figure's bones whenever the answer is no.

computeBoundingSphere, boundingSphere and frustumCulled appeared nowhere in renderer.ts.

The joints survive because each is its own Mesh with its own moving transform, so its bounds travel with it. That asymmetry is the symptom: lines gone, nodes still there, depending on where you orbit.

Reproduced, and verified fixed

Against the installed three, body 4 m out, camera orbiting it at the renderer's own 3.55 m and 46°:

stale sphere (what three cached): centre (0, 0, 0) radius 0
true sphere  (where the body is): centre (4, 1, 0) radius 0

  angle    before    after
    0°     GONE      drawn
   45°     drawn     drawn
   90°     drawn     drawn
  135°     drawn     drawn
  180°     GONE      drawn
  225°     GONE      drawn
  270°     GONE      drawn
  315°     GONE      drawn

bones lost at 5 of 8 angles before, 0 of 8 after

Every one of those rows has the body fully on screen.

Why nothing caught it before

It needs the body away from the origin to appear. The fixtures travel 0.46 m at most (slip-away, the only one that travels at all) and keep the origin inside the figure, so fixture mode hides it completely. A real model covers 2–4 m and separates the two — so this is only reachable with the workers running, which is also why no test would have found it.

The fix

frustumCulled = false on both line objects.

Recomputing the sphere would also work, but it would have to be remembered at every site that writes positions — applyFrame is reached from seek, seekSegment and loadSequence as well — and forgetting one is how this arose. There are at most five line objects on the stage, so culling them buys nothing worth that risk. Two constructors are harder to get wrong than four writers.

Both sites, not just the visible one. The ghost-cloud's bones are built identically and each sibling has its own, so they could blink out one at a time. That is worst precisely where travel is what is being read, since roughly three quarters of the spread between siblings is how far each one goes.

Not in this PR

No test. This is a renderer property rather than pure logic, and the suite has no WebGL — notation.test.ts drives a hand-rolled DOM stub. The reproduction above runs against real three in Node and needs no GPU, so it could become the repo's first renderer test, but three is not currently importable from node --test without a path hack. Raising it rather than quietly skipping it.

tsc clean, 87 pass, 0 fail. Branched off main, so it is independent of #29 and can go in first whatever is decided about the grid.

🤖 Generated with Claude Code

https://claude.ai/code/session_014yJSPiRjB5WvTH2x4LB8V6

At some camera angles the amber bones vanished while the joints stayed. The
bones are one LineSegments whose vertices are rewritten in place every frame;
applyFrame sets needsUpdate, which re-uploads them to the GPU and does not
touch the bounding sphere. three computes that sphere once, lazily, on its
first cull test — and at that moment the buffer is still zero-filled, so it
caches centre (0,0,0) radius 0, a point at the world origin, and keeps it for
the life of the figure. The renderer then asks whether the origin is in view
and throws the whole figure's bones away whenever the answer is no.

The joints survive because each is its own Mesh with its own moving transform,
so its bounds travel with it. That asymmetry is the symptom: lines gone, nodes
still there, depending on where you orbit.

Reproduced against the installed three with the body 4 m out and the camera
orbiting it at the renderer's own 3.55 m and 46 degrees: bones lost at five of
eight angles with the body fully on screen, none after the fix.

It needs the body away from the origin to appear, which is why nothing showed
it until now — the fixtures travel 0.46 m at most and keep the origin inside
the figure, while a real model covers 2-4 m and separates the two.

Fixed by not culling either line object. Recomputing the sphere would also
work, but it would have to be remembered at every site that writes positions —
applyFrame is reached from seek, seekSegment and loadSequence as well — and
forgetting one is how this arose. There are at most five line objects on the
stage, so culling them buys nothing worth that risk.

The ghost-cloud's bones are built the same way and each sibling has its own, so
they could blink out one at a time. That is worst precisely where travel is
what is being read, since roughly three quarters of the spread between siblings
is how far each one goes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014yJSPiRjB5WvTH2x4LB8V6
@WWStoryMode
WWStoryMode merged commit 37bfa5a into main Oct 19, 2026
2 checks passed
@WWStoryMode
WWStoryMode deleted the fix/bones-culled-against-the-origin branch October 19, 2026 13:59
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.

1 participant