@promptbook/remote-server
Version:
Promptbook: Create persistent AI agents that turn your company's scattered knowledge into action
142 lines (141 loc) • 4.42 kB
TypeScript
/**
* One 3D point used by the shared avatar projection helpers.
*
* @private helper of the 3D avatar visuals
*/
export type Point3D = {
readonly x: number;
readonly y: number;
readonly z: number;
};
/**
* One projected 2D point derived from scene-space 3D coordinates.
*
* @private helper of the 3D avatar visuals
*/
export type ProjectedPoint = {
readonly x: number;
readonly y: number;
readonly z: number;
};
/**
* Default camera distance ratio shared by the proper-3D avatar visuals.
*
* @private helper of the 3D avatar visuals
*/
export declare const DEFAULT_3D_CAMERA_DISTANCE_RATIO = 1.4;
/**
* Clamps one number into the provided range.
*
* @param value Input value.
* @param minimumValue Inclusive lower bound.
* @param maximumValue Inclusive upper bound.
* @returns Clamped value.
*
* @private helper of the 3D avatar visuals
*/
export declare function clampNumber(value: number, minimumValue: number, maximumValue: number): number;
/**
* Rotates one point around the local Y axis.
*
* @param point Source point.
* @param angle Rotation angle in radians.
* @returns Rotated point.
*
* @private helper of the 3D avatar visuals
*/
export declare function rotatePointAroundY(point: Point3D, angle: number): Point3D;
/**
* Rotates one point around the local X axis.
*
* @param point Source point.
* @param angle Rotation angle in radians.
* @returns Rotated point.
*
* @private helper of the 3D avatar visuals
*/
export declare function rotatePointAroundX(point: Point3D, angle: number): Point3D;
/**
* Applies the local rotations and translation to one scene point.
*
* @param localPoint Point in local object space.
* @param center Object center in scene space.
* @param rotationX Object pitch in radians.
* @param rotationY Object yaw in radians.
* @returns Transformed scene-space point.
*
* @private helper of the 3D avatar visuals
*/
export declare function transformScenePoint(localPoint: Point3D, center: Point3D, rotationX: number, rotationY: number): Point3D;
/**
* Projects one scene point into canvas coordinates.
*
* @param point Scene-space point.
* @param size Canvas size in CSS pixels.
* @param sceneCenterX Horizontal scene center.
* @param sceneCenterY Vertical scene center.
* @param cameraDistanceRatio Optional camera distance ratio.
* @returns Projected point.
*
* @private helper of the 3D avatar visuals
*/
export declare function projectScenePoint(point: Point3D, size: number, sceneCenterX: number, sceneCenterY: number, cameraDistanceRatio?: number): ProjectedPoint;
/**
* Interpolates between two projected points.
*
* @param startPoint Start point.
* @param endPoint End point.
* @param ratio Interpolation ratio in the range `[0, 1]`.
* @returns Interpolated projected point.
*
* @private helper of the 3D avatar visuals
*/
export declare function interpolateProjectedPoint(startPoint: ProjectedPoint, endPoint: ProjectedPoint, ratio: number): ProjectedPoint;
/**
* Subtracts one 3D point from another.
*
* @param leftPoint Left point.
* @param rightPoint Right point.
* @returns Difference vector.
*
* @private helper of the 3D avatar visuals
*/
export declare function subtractPoint3D(leftPoint: Point3D, rightPoint: Point3D): Point3D;
/**
* Computes the 3D cross product of two vectors.
*
* @param leftVector Left vector.
* @param rightVector Right vector.
* @returns Cross product.
*
* @private helper of the 3D avatar visuals
*/
export declare function crossProduct3D(leftVector: Point3D, rightVector: Point3D): Point3D;
/**
* Computes the 3D dot product of two vectors.
*
* @param leftVector Left vector.
* @param rightVector Right vector.
* @returns Dot product.
*
* @private helper of the 3D avatar visuals
*/
export declare function dotProduct3D(leftVector: Point3D, rightVector: Point3D): number;
/**
* Normalizes one 3D vector while keeping zero vectors stable.
*
* @param vector Source vector.
* @returns Normalized vector.
*
* @private helper of the 3D avatar visuals
*/
export declare function normalizeVector3(vector: Point3D): Point3D;
/**
* Measures the perimeter of one projected quad.
*
* @param corners Quad corners.
* @returns Perimeter length.
*
* @private helper of the 3D avatar visuals
*/
export declare function getProjectedQuadPerimeter(corners: readonly [ProjectedPoint, ProjectedPoint, ProjectedPoint, ProjectedPoint]): number;