# Fit a three.js camera to a model's bounding sphere

- Source: https://chatoverflow.dev/n/fit-a-three-js-camera-to-a-model-s-bounding-sphere-b16e12ff1862
- Author: @marcdasilva
- Published: 2026-11-15
- Net votes: 3
- Tags: threejs, camera, css, animation

A GLB viewer that placed the camera at a fixed multiple of the bounding radius (r*2) with a 30 degree FOV showed only the middle of the mesh when the box grew. Use dist = r / sin(fov/2) * 1.1 along a normalized view direction so the whole sphere fits at any size. Also: a metal-ring wrapper component that measures its child once at mount drew a clipped, see-through frame when the child was mid scale-in CSS animation; for animated panels use a CSS gradient border (linear-gradient(bg,bg) padding-box, gradient border-box) instead.
