Reference
Optics
Pinhole camera frusta and stereo rigs.
import { ... } from 'cseen/optics';Functions
Section titled “Functions”frustum
Section titled “frustum”A pinhole camera with its image plane and rays.
function frustum(o?: FrustumOpts): Frustum| Parameter | Type |
|---|---|
o? | FrustumOpts |
Returns Frustum
Options: FrustumOpts
Example
import { Scene, box, ground } from 'cseen';import { frustum } from 'cseen/optics';
const s = new Scene({ view: { yaw: 62, pitch: 22 } });s.add(ground(), box({ at: [1.4, 5, 0], size: [1, 1, 1.4], role: 'faint' }));s.add(frustum({ at: [-1, -1, 1.6], target: [0.4, 5, 0.6], f: 1.6, fov: 46, depth: 4.6, labels: true }));stereoRig
Section titled “stereoRig”Two cameras looking at one point: the picture behind stereo vision and depth from disparity.
function stereoRig(o?: StereoOpts): StereoRig| Parameter | Type |
|---|---|
o? | StereoOpts |
Returns StereoRig
Options: StereoOpts
Example
import { Scene, ground } from 'cseen';import { stereoRig } from 'cseen/optics';
const s = new Scene({ view: { yaw: 20, pitch: 55 } });s.add(ground(), stereoRig({ baseline: 2.4, f: 1.5, point: [0.4, 4.2, 0.5] }));Classes
Section titled “Classes”Frustum
Section titled “Frustum”The classic picture of a pinhole camera: the centre, the image plane at focal length f, the rays through its
corners and the optical axis. Give it points and it projects them. f and fov animate.
new Frustum(o?: FrustumOpts): FrustumOptions: FrustumOpts
Extends Node.
| Member | Description |
|---|---|
o: FrustumOpts | |
centre(): (): V3 | the camera centre, as an anchor that follows the node |
project(P: V3): V3 | null | where a point (in the node’s space) lands on the image plane, in world space, or null if behind the camera |
collect(out: Prim[]): void | appends what this node draws right now to out, in world coordinates. Draws nothing when fully transparent. |
StereoRig
Section titled “StereoRig”Two parallel cameras a baseline apart looking at one point: both image planes, both rays, the horizontal
epipolar lines, and the depth Z = f * b / d. baseline, f, fov and point animate, so you can watch the
disparity shrink as the point moves away.
new StereoRig(o?: StereoOpts): StereoRigOptions: StereoOpts
Extends Node.
| Member | Description |
|---|---|
o: StereoOpts | |
disparity(): number | disparity: how far apart the two image points are along x, in world units. The depth is f * b / disparity. |
depth(): number | the depth recovered from the disparity, f * b / d. It equals the point’s distance from the baseline. |
collect(out: Prim[]): void | appends what this node draws right now to out, in world coordinates. Draws nothing when fully transparent. |
Options and types
Section titled “Options and types”FrustumOpts
Section titled “FrustumOpts”Options of frustum.
Extends NodeOpts.
| Option | Type | Default | Description |
|---|---|---|---|
target? | V3 | the point the camera looks at, in the node’s space. Default: straight ahead along +y. | |
f? | number | focal length: how far the image plane is from the camera centre. Animatable. | |
fov? | number | vertical field of view in degrees. Sets the size of the image plane. Animatable. | |
aspect? | number | width over height of the image plane | |
depth? | number | how far the rays reach | |
points? | Point[] | points to project. A plain [x, y, z] is in the camera’s own space; a node or an anchor is wherever it is in the scene, and follows when either moves. Each gets a ray to the camera and a dot where it lands on the image plane | |
far? | boolean | draw the far end of the pyramid too | |
labels? | boolean | write C, f, and the name of the image plane | |
epipolar? | boolean | draw a horizontal line across the image plane through each projected point (the epipolar line of a rectified pair) | |
roll? | number | tilt the camera about its own axis, in degrees | |
role? | string | colour role (ink, faint, accent, s1 to s8) or a role you define in CSS |
StereoOpts
Section titled “StereoOpts”Options of stereoRig.
Extends NodeOpts.
| Option | Type | Default | Description |
|---|---|---|---|
baseline? | number | distance between the two cameras. Animatable. | |
f? | number | focal length of both cameras | |
fov? | number | vertical field of view in degrees | |
aspect? | number | width over height of the image planes | |
point? | V3 | the point both cameras see, in the rig’s space. Animatable. | |
depth? | number | how far the rays reach | |
labels? | boolean | write the names of the parts | |
role? | string | colour role (ink, faint, accent, s1 to s8) or a role you define in CSS |