@three3d/tools
Version:
@three3d/tools 提供了 ThreeJS 常用的工具库
220 lines • 5.8 kB
TypeScript
import { Vector3 } from "three";
import type { FrenetFrame } from "../math";
/**
* 零的阀值
* @remarks
* 绝对值小于该值的都认为是零
*/
export declare const zeroThreshold_Default = 0.1;
/**
* 创建对称分段的三角面索引
* @remarks
* 当几何体两侧总有对称的顶点时,可用此方法来为其构建三角面索引
* @param vertexCount - 顶点个数
* @param startIndex - 开始索引
* @param connectPre - 是否和之前的面进行拼接
*/
export declare function createSymmetricSegmentedTrigonometricIndexs(vertexCount: number, startIndex?: number, connectPre?: boolean | null): number[];
/**
* 创建对称分段的三角面索引
* @remarks
* 当几何体两侧总有对称的顶点时,可用此方法来为其构建三角面索引
* 本方法会根据转角方向来设置三角面,以使其看起来更合理
* @param vertexCount - 顶点个数
* @param startIndex - 开始索引
* @param connectPre - 是否和之前的面进行拼接
*/
export declare function createSymmetricSegmentedTrigonometricIndexsByVertexs(vertexs: ArrayLike<number>, startIndex?: number, connectPre?: boolean | null): number[];
/**
* 线的衔接类型
*/
export declare enum LineConnectionType {
/**
* 斜角
*/
bevel = "bevel",
/**
* 斜切
*/
chamfer = "chamfer",
/**
* 圆
*/
round = "round",
/**
* 线段
*/
lineSegment = "lineSegment"
}
export interface VertexInfo {
point: Vector3;
length: number;
width: number;
}
/**
* 创建斜角的线连接数据
* @param cornerPointInfo
* @param frontFrame
* @param backFrame
* @param chamfer - 是否斜切
* @param zeroThreshold - 零的阀值;绝对值小于该值的都认为是零
* @returns
*/
export declare function createBevelLineConnection(cornerPointInfo: VertexInfo, frontFrame: FrenetFrame, backFrame: FrenetFrame, chamfer?: boolean, zeroThreshold?: number): {
points: Vector3[];
normals: Vector3[];
lengths: number[];
};
export interface CreateRoundLineConnectionOptions {
/**
* 圆形衔接角的步长角
* @remarks
* 与 smoothStepLength 作用相同
* smoothStepAngle 的优先级高于 smoothStepLength
*/
smoothStepAngle?: number;
/**
* 圆形衔接角的长度步长
* @remarks
* 与 smoothStepAngle 作用相同
* smoothStepAngle 的优先级高于 smoothStepLength
*/
smoothStepLength?: number;
}
/**
* 表示两个 FrenetFrame 的关系
*/
export declare enum FrenetFrameRelation {
/**
* 所有的轴都是斜着的
* @remarks
* 即:所有的轴都不平行也不垂直
*/
AllOblique = 0,
/**
* 切线同向
*/
TangentSame = 1,
/**
* 切线反向
*/
TangentReverse = 2,
/**
* 切线垂直
*/
TangentVertical = 4,
/**
* 法线同向
*/
NormalSame = 8,
/**
* 法线反向
*/
NormalReverse = 16,
/**
* 法线垂直
*/
NormalVertical = 32,
/**
* 副法线同向
*/
BinormalSame = 64,
/**
* 副法线反向
*/
BinormalReverse = 128,
/**
* 副法线垂直
*/
BinormalVertical = 256
}
/**
* 计算FrenetFrame各轴的平行和垂直关系
* @param frontFrame
* @param backFrame
* @param zeroThreshold
* @returns
*/
export declare function computeFrenetFrameRelation(frontFrame: FrenetFrame, backFrame: FrenetFrame, zeroThreshold?: number): FrenetFrameRelation;
/**
* 交线的关系
*/
export interface IntersectionLineInfo {
/**
* 两个带的相交关系
*/
relation: FrenetFrameRelation;
line?: {
/**
* 交线的切线方向
*/
tangent: Vector3;
/**
* 交线的切线方向
*/
normal: Vector3;
/**
* 交结的长度
*/
length: number;
};
}
/**
* 计算两个带的交线
* @remarks
* 假设带的功宽度为1
* @param frontFrame
* @param backFrame
* @param zeroThreshold
* @returns
*/
export declare function computeIntersectionLineOfBands(frontFrame: FrenetFrame, backFrame: FrenetFrame, zeroThreshold?: number): IntersectionLineInfo;
/**
* 创建圆角的线连接数据
* @param cornerPointInfo
* @param frontFrame
* @param backFrame
* @param options - 圆角选项
* @param zeroThreshold - 零的阀值;绝对值小于该值的都认为是零
* @returns
*/
export declare function createRoundLineConnection(cornerPointInfo: VertexInfo, frontFrame: FrenetFrame, backFrame: FrenetFrame, options?: CreateRoundLineConnectionOptions, zeroThreshold?: number): {
points: Vector3[];
normals: Vector3[];
lengths: number[];
};
/**
* 创建线段连接器
* @remarks
* 只是简单地将两个线段连接起来
* @param cornerPointInfo
* @param frontFrame
* @param backFrame
* @param chamfer
* @returns
*/
export declare function createLineSegmentConnection(cornerPointInfo: VertexInfo, frontFrame: Omit<FrenetFrame, "tangent">, backFrame: Omit<FrenetFrame, "tangent">): {
points: Vector3[];
normals: Vector3[];
lengths: number[];
};
export interface CreateLineConnectionOptions extends CreateRoundLineConnectionOptions {
/**
* 线的连接类型
*/
connectionType: LineConnectionType;
}
/**
* 创建圆角的线连接数据
* @param cornerPointInfo
* @param frontFrame
* @param backFrame
* @param options - 选项
* @returns
*/
export declare function createLineConnection(cornerPointInfo: VertexInfo, frontFrame: Omit<FrenetFrame, "">, backFrame: FrenetFrame, options?: CreateLineConnectionOptions): {
points: Vector3[];
normals: Vector3[];
lengths: number[];
};
//# sourceMappingURL=band.d.ts.map