@three3d/tools
Version:
@three3d/tools 提供了 ThreeJS 常用的工具库
184 lines • 4.33 kB
TypeScript
import type { IVector3 } from "type-tls";
import { Vector3 } from "three";
/**
* 角度范围
* @remarks
* - 可以是 [start,end] 也可以是 [end,start],即:可以第一个值 可以在于 第二个值
* - 范围始终包含 第一个值,不包含第二个值
*/
export type AngleRange = [number, number];
/**
* 方位映射
*/
export type AzimuthMap = Record<string, [number, number]>;
/**
* 方位范围,用来描述方位对应的角度范围
*/
export interface AzimuthRange {
name: string;
range: [number, number];
}
/**
* 方位范围列表
*/
export type AzimuthList = AzimuthRange[];
/**
* 方位定义
*/
export type AzimuthDefine = AzimuthList | AzimuthMap;
/**
* 航向方位映射
*/
export interface CourseAzimuthMap<Define extends AzimuthDefine = AzimuthDefine> {
/**
* 偏航角
* @remarks
* - 旋转轴 上方向量
* - 起始向量:前方向量
*/
yaw?: Define | null;
/**
* 俯仰角
* @remarks
* - 旋转轴 右方向量
* - 起始向量:前方向量
*/
pitch?: Define | null;
/**
* 横滚角
* @remarks
* - 旋转轴 后方向量
* - 起始向量:上方向量
*/
roll?: Define | null;
}
/**
* 默认的方位映射
* @remarks
* 将每个旋转面都成了4份:
* - [-15,15]
* - [15,165]
* - [-165,-15]
* - [165,-165]
*/
export declare const defaultCourseAzimuthMap: CourseAzimuthMap;
export interface AzimuthInfo {
/**
* 角度
*/
angle: number;
/**
* 所有匹配的名字
*/
name: string[];
}
/**
* 航向信息
*/
export interface CourseInfo {
/**
* 偏航角
* @remarks
* - 旋转轴 上方向量
* - 起始向量:前方向量
*/
yaw: AzimuthInfo;
/**
* 俯仰角
* @remarks
* - 旋转轴 右方向量
* - 起始向量:前方向量
*/
pitch: AzimuthInfo;
/**
* 横滚角
* @remarks
* - 旋转轴 后方向量
* - 起始向量:上方向量
*/
roll: AzimuthInfo;
}
/**
* 格式化方位定义映射对象
* @param map
* @returns
*/
export declare function formatAzimuthDefineMap(map: CourseAzimuthMap): CourseAzimuthMap<AzimuthList>;
/**
* Azimuth 的选项
*/
export interface AzimuthOptions {
/**
* 是否使用角度,而非弧度
* @defaultValue true
*/
degrees?: boolean | null;
/**
* 方位映射定义
*/
map?: CourseAzimuthMap | null;
/**
* 前方向量
* @defaultValue {x:0,y:0,z:1}
*/
front?: IVector3;
/**
* 前方向量
* @defaultValue {x:0,y:1,z:0}
*/
up?: IVector3;
}
/**
* 默认选项
*/
export declare const defaultAzimuthOptions: Required<AzimuthOptions>;
/**
* 计算方位的类
*/
export declare class Azimuth {
constructor(options?: AzimuthOptions);
static get options(): AzimuthOptions;
static set options(value: AzimuthOptions);
protected static _options?: AzimuthOptions | null;
/**
* 默认选项
*/
protected get defaultOptions(): AzimuthOptions;
get options(): AzimuthOptions;
set options(value: AzimuthOptions);
protected _options?: AzimuthOptions | null;
/**
* 是否使用角度,而非弧度
*/
get degrees(): boolean;
set degrees(value: boolean);
get map(): CourseAzimuthMap<AzimuthDefine> | null | undefined;
set map(value: CourseAzimuthMap<AzimuthDefine> | null | undefined);
protected get listMap(): CourseAzimuthMap<AzimuthList>;
protected _listMap?: CourseAzimuthMap<AzimuthList> | null;
get front(): IVector3;
set front(value: IVector3);
protected _front?: Vector3 | null;
get up(): IVector3;
set up(value: IVector3);
protected _up?: Vector3 | null;
/**
* 计算方位
* @param target
* @param front
* @param up
*/
computeAzimuth(target: IVector3, front?: IVector3 | null, up?: IVector3 | null): CourseInfo;
/**
* 查找匹配的方位名字
* @param type - 类型
* @param angle - 角度
* @returns 匹配的名字列表
*/
findAzimuthNames(type: keyof CourseAzimuthMap, angle: number): string[];
}
/**
* 计算方位对象
*/
export declare const azimuth: Azimuth;
//# sourceMappingURL=Azimuth.d.ts.map