FrameParams
Since 0.7
{@link ViewsHandle.frame}'s options.
Absent or invalid numbers keep the default.
Signature
export interface FrameParams {
/** The direction the camera looks from, radians, as the orbit rig's: 0 looks along -Z. Default 0. */
yaw?: number
/** Radians, positive looks up. Default -0.9 (looking down at the targets). */
pitch?: number
/** Closest the camera comes to the targets' centre, metres. Default 4. */
minDistance?: number
/** Furthest it pulls back, metres. Default 60. */
maxDistance?: number
/** Metres of room round the targets. Default 1.5. */
padding?: number
/** How fast the camera catches up, per second of game time; 0 snaps. Default 4. */
smoothing?: number
/** Vertical field of view, degrees. Default: the scene camera's. */
fov?: number
/** Widest field of view, degrees, the camera may open to once it is at `maxDistance`. Default: none. */
maxFov?: number
}
Import: import type { FrameParams } from "@argus/api"
Members
| Member | Signature | Description |
|---|---|---|
yaw | yaw?: number | The direction the camera looks from, radians, as the orbit rig's: 0 looks along -Z. Default 0. |
pitch | pitch?: number | Radians, positive looks up. Default -0.9 (looking down at the targets). |
minDistance | minDistance?: number | Closest the camera comes to the targets' centre, metres. Default 4. |
maxDistance | maxDistance?: number | Furthest it pulls back, metres. Default 60. |
padding | padding?: number | Metres of room round the targets. Default 1.5. |
smoothing | smoothing?: number | How fast the camera catches up, per second of game time; 0 snaps. Default 4. |
fov | fov?: number | Vertical field of view, degrees. Default: the scene camera's. |
maxFov | maxFov?: number | Widest field of view, degrees, the camera may open to once it is at maxDistance. Default: none. |
Example
The tested fixture fixtures/host/hover.ts.
import type { Behavior, Ctx, Vec3 } from "@argus/api"
// docs/API.md, "Forces, torques and impulses": a body that hovers (thrust = m·g), and the same lift
// as four rotors in the airframe's own frame plus a yaw torque. Typechecked by packages/api's tests.
const HUBS: Vec3[] = [[0.3, 0, 0.3], [-0.3, 0, 0.3], [0.3, 0, -0.3], [-0.3, 0, -0.3]]
function hover(ctx: Ctx) {
const body = ctx.body
if (!body) return
if (ctx.props["rotors"] !== true) {
body.addForce([0, body.mass * 9.81, 0])
return
}
for (const h of HUBS) body.addForceAtPoint([0, (body.mass * 9.81) / 4, 0], h, "local")
body.addTorque([0, (ctx.props["yaw"] as number | undefined) ?? 0, 0], "local")
}
export default {
// The first physics step runs before the first update; this is its thrust.
init(ctx) { hover(ctx) },
update(ctx) { hover(ctx) },
} satisfies Behavior