mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-09-30 03:01:21 +02:00
Model preview ------------- The camera distance came from `maxDim * 1.8`, which accounts for neither the camera's field of view nor the viewport's aspect ratio, so a tall narrow panel was framed as though it were square -- the model sat in the middle with a screenful of dead space above it. Solved from the bounding sphere against both fields of view instead, so it fills the frame at any panel shape. Near/far now scale to the subject rather than staying at the 0.1/10000 defaults. Lighting was two directional lamps over 0.6 flat ambient on a Phong material: every surface facing the same way got an identical colour, which is what flattened models into silhouettes. Now a MeshStandard material lit by a generated RoomEnvironment through PMREMGenerator, with ACES tone mapping so the lit side of a saturated filament colour doesn't clip to white and drain the hue. Added a contact shadow. Two things would have made it silently draw nothing: the build plate is an unlit MeshBasicMaterial and cannot receive shadows, so the catcher is a separate ShadowMaterial plane; and three's default directional shadow camera is a +/-5 unit box, which nothing on a 256mm bed falls inside. The PMREM render target is disposed on unmount -- it is GPU memory the collector cannot reclaim, and this viewer is opened and closed repeatedly from the file manager. Device pixel ratio is capped at 2; a 3x phone screen was quadrupling fragment load for no visible gain. G-code preview -------------- Switched gcode-preview from `lineWidth: 2` to `renderTubes`. A 2px screen-space line has no thickness in the scene, so it cannot occlude the layer behind it -- hence the stringy surface and the shimmer where layers overlap. Tubes are built from real extrusion width and height, so the print occludes itself. The flag is marked experimental upstream, and the 0.42 extrusion width is a hardcoded default that is right for a 0.4 nozzle and wrong for a 0.6. Both are worth revisiting if this holds up in use. Modal ----- Removed the G-code tab. G-code has its own full-page viewer, and a preview of a model is a different question from a preview of a print. That left dead weight behind it: the render branch, the GcodeViewer import, the has_gcode capability (still computed, never read), the Code2 icon, and two orphaned strings in all 13 locales. One test was repurposed to assert the tab is absent so it cannot creep back; two others only exercised that tab's disabled state and went with it.