/** * Draws a capsule along its y-axis, with handles that drag its radius and its height, caps * included. A height edit keeps the center in place. * * ```javascript * const gizmo = new CapsuleGizmo(cameraComponent, layer); * gizmo.on('handle:move', () => { * collision.radius = gizmo.radius; * collision.height = gizmo.height; * }); * ``` * * Relevant Engine API examples: * * - [Shape Gizmos](https://playcanvas.github.io/#/gizmos/shape) * * @category Gizmo */ export class CapsuleGizmo extends ShapeGizmo { /** * Creates a new CapsuleGizmo object. * * @param {CameraComponent} camera - The camera component. * @param {Layer} layer - The render layer. * @example * const gizmo = new CapsuleGizmo(camera, layer); */ constructor(camera: CameraComponent, layer: Layer); /** * The radius of the capsule. Defaults to 0.5. * * @type {number} */ radius: number; /** * The height of the capsule, caps included, at least twice its radius. Defaults to 2. * * @type {number} */ height: number; /** * The first result of {@link CapsuleGizmo#_offset}. * * @private */ private _a; /** * The second result of {@link CapsuleGizmo#_offset}. * * @private */ private _b; /** * Places the outline of the capsule as the camera sees it. * * @param {Vec3} top - The center of the top cap. * @param {Vec3} bottom - The center of the bottom cap. * @param {Vec3} up - The axis of the capsule. * @param {number} radius - The radius. * @private */ private _outline; /** * Places the outline of a cap beyond the body, or all of it when viewed along the axis. * * @param {Vec3} center - The center of the cap. * @param {Vec3} axis - The direction the cap faces. * @param {Vec3|null} across - The unit direction across the axis to the camera, or null. * @param {number} radius - The radius. * @param {number} [cos] - The cosine of where the sides meet the cap, from the direction across. * @private */ private _capOutline; /** * @param {Vec3} point - The point. * @param {Vec3} dir - The direction. * @param {number} distance - The distance along the direction. * @param {number} slot - Which of the two results to write. * @returns {Vec3} The point moved along the direction. * @private */ private _offset; } import { ShapeGizmo } from './shape-gizmo.js'; import type { CameraComponent } from '../../../framework/components/camera/component.js'; import type { Layer } from '../../../scene/layer.js';