From aa6e991277c96484c8e605f49db05019fe2c65aa Mon Sep 17 00:00:00 2001 From: William Wong Date: Mon, 19 Oct 2026 14:54:18 +0100 Subject: [PATCH] fix(renderer): the bones were culled against the origin, not the body MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Claude-Session: https://claude.ai/code/session_014yJSPiRjB5WvTH2x4LB8V6 --- frontend/app/src/renderer.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/frontend/app/src/renderer.ts b/frontend/app/src/renderer.ts index 2c748b2..b2aae67 100644 --- a/frontend/app/src/renderer.ts +++ b/frontend/app/src/renderer.ts @@ -230,6 +230,10 @@ export class StickFigureRenderer { }), ); lines.visible = this.ghostsVisible; + // Same stale-bounds problem as the primary figure's bones, and each sibling has its + // own, so they could blink out one at a time — exactly where travel is the thing + // being read, since most of the spread between siblings IS how far each one goes. + lines.frustumCulled = false; this.scene.add(lines); this.ghosts.push({ motion, lines, attr }); } @@ -359,6 +363,23 @@ export class StickFigureRenderer { boneGeo, new THREE.LineBasicMaterial({ color: this.boneColor }), ); + // Never frustum-culled, because its bounds are a lie. + // + // This geometry's vertices are rewritten every frame in place (applyFrame) and only the + // GPU upload is invalidated — `needsUpdate` 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: it caches centre (0,0,0) radius 0, a point at the world + // origin, and keeps it forever. The renderer then asks "is the origin in view?" and + // throws the whole figure's bones away whenever the answer is no — which is why the + // bones vanished at some camera angles while the joints, each its own Mesh with its own + // moving transform, stayed. It needs the body away from the origin to show, so fixtures + // (0.46 m at most) hid it and real models (2-4 m) do not. + // + // 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. + this.boneLines.frustumCulled = false; this.scene.add(this.boneLines); // trails — a small stack of fading ghost spheres per tracked joint