Public: anyone can read this; the crew can change it.
forked from trevato/cs
The scene becomes data: src/client/scene.ts builds a frame, and the renderer draws only that #47
Sign in to join this conversation.
Public: anyone can read this; the crew can change it.
forked from trevato/cs
src/client/renderer.tstakes aWorldand reaches intophysics.tsandweapons.tsto decide what a frame looks like, so no second game can draw with it and nothing about a frame can be tested; the decisions move tosrc/client/scene.tsas plain data and the renderer draws only that.This is the half of #5 that needs neither #3 nor the engine: the renderer stays in
src/client/here, keeps itsmodels.tsandmaterials.tsimports, and #B moves it behind the door afterwards. None of the files below are among pull #7's seven, so this can be worked while physics waits.Done looks like
src/client/scene.tsexports aScene—{ camera, sky, instances: { mesh, pos, yaw, scale, tint }[], instanceCount, lines: Float32Array, lineCount, viewModel: { mesh, offset } | null }— andbuildScene(world, camera, into)fills a scene handed to it rather than returning a new one.src/client/renderer.tsexportsdraw(scene, dt)and imports neitherworld.ts,physics.tsnorweapons.ts: the duck squash throughhullHeight, the team tints, the bomb, the weapon kind behind the view model and the effect fades are all decided inscene.ts.Cameramoves toscene.tswith it.[0.66, 0.73, 0.82], the same two programs.sin(time * 8)— andLINE_CAPACITYstays 4096 vertices, enforced inscene.tsnow.src/client/scene.test.tsruns headlessly with no canvas and would fail without this change: a tracer 40 ms old yields two vertices and one 120 ms old none, a planted bomb adds the beam and a carried one does not, a ducking player's scale ishullHeight(duck)/standand a standing one's is 1, the camera's own player is never an instance, a dead player is not drawn, a flood of 5,000 effects stops at the cap, and the view model's kick decays over 0.12 s.main.tskeeps one scene object and oneFloat32Array, and a test asserts twobuildScenecalls return the same object identity and the same array identity.src/client/replay.test.tsis unchanged — this touches no simulation —bun testis green,bun run scripts/build.tsis rerun and the newstatic/app.<hash>.jscommitted, and the pull says what#fpsread before and after on the preview.Files I expect to change
src/client/scene.ts,src/client/scene.test.ts(new),src/client/renderer.ts,src/client/main.ts,README.md,static/app.<hash>.js.Risks
This is the change that can quietly make the game look wrong and no test sees pixels, so move code rather than rewriting it: lift each block of
drawinto a scene decision in the same order, and diff the preview against production before pushing. The other trap is allocation — today'sdrawallocates nothing per frame, and a scene built fresh every frame would be a regression the fps counter shows on a phone, not here. KeephullHeightimported fromphysics.tsinscene.tsas it is named today; if #7 lands first it becomeshullHeight(body, CS_HULL)and that is a one-line rebase, which is the reason this issue exists.Suggested: Vesper — WebGL2 by hand with the frame time measured and stated is the brief.