xtorcga
Version:
Xtor Compute Geometry Algorithm Libary 计算几何算法库
196 lines (195 loc) • 5.96 kB
TypeScript
import { Vec3, IVec3, IVec2 } from '../math/Vec3';
import { Vec2 } from '../math/Vec2';
import { AxisPlane } from './trianglution';
import { IGeometry } from '../render/geometry';
import { ArrayList } from '../struct/data/ArrayList';
export interface ILinkSideOption {
side0: {
x: number;
y: number;
z: number;
index?: number;
}[] | number[];
side1: {
x: number;
y: number;
z: number;
index?: number;
}[] | number[];
holes0?: Array<Array<Vec3>>;
holes1?: Array<Array<Vec3>>;
shapeClosed?: boolean;
autoUV?: boolean;
uvScalars?: number[];
segs?: [];
}
/**
* 常用shape几何操作
*/
/**
* @description : 缝合两个边 不提供uv生成 uv有@linkSides 生成
* @param { ILinkSideOption } options
* @returns { Array<Vec3>} 三角形数组,每三个为一个三角形
* @example :
*/
export declare function linkSide(options: ILinkSideOption): number[];
/**
* 缝合shape集合
* @param {Array<Array<Point|Vec3>} shapes 路基 点集的集合, 每个shape的点数量一致
* @param {Boolean} sealStart 每一个shape是否是封闭的界面 默认false
* @param {Boolean} isClosed 每一个shape是否是封闭的界面 默认false
* @param {Boolean} isClosed2 每一个shape是否是封闭的首尾 默认false
* @returns {Array} 返回三角形集合 如果有所用范围索引,否则返回顶点
*/
export interface ILinkSideOptions {
shapes: Array<Array<IVec3 | any | IVec3>>;
orgShape?: Array<IVec3 | any | IVec3>;
orgHoles?: any;
sealStart?: boolean;
sealEnd?: boolean;
shapeClosed?: boolean;
pathClosed?: boolean;
index?: {
index: number;
};
autoIndex?: boolean;
generateUV?: boolean;
axisPlane?: AxisPlane;
holes?: Array<Array<IVec3 | any | IVec3>>[];
}
/**
* @description : 链接多个shape 生成几何体
* @param {ILinkSideOptions} optionsILinkSideOptions {
* shapes: Array<Array<IVec3 | number | any>>;
* sealStart?: boolean,//开始封面
* sealEnd?: boolean;//结束封面
* shapeClosed?: boolean,//shape是否闭合
* pathClosed?: boolean,//路径是否闭合
* index?: { index: number },
* generateUV?: boolean
* }
*
* @return {*}
* @example :
*
*/
export declare function linkSides(options: ILinkSideOptions): IGeometry;
export interface IExtrudeOptions {
fixedY?: boolean;
shapeClosed?: boolean;
isClosed2?: boolean;
textureEnable?: boolean;
textureScale?: Vec2;
smoothAngle?: number;
sealStart?: boolean;
sealEnd?: boolean;
normal?: Vec3;
}
export interface IExtrudeOptionsEx {
shape: Array<Vec3 | IVec3 | Vec2 | IVec2>;
path: Array<Vec3 | IVec3>;
ups?: Array<Vec3 | IVec3>;
up?: Vec3 | IVec3;
right?: Vec3;
shapeClosed?: boolean;
pathClosed?: boolean;
textureEnable?: boolean;
smoothAngle?: number;
enableSmooth?: boolean;
sealStart?: boolean;
sealEnd?: boolean;
normal?: Vec3;
autoIndex?: boolean;
axisPlane?: AxisPlane;
generateUV?: boolean;
index?: {
index: number;
};
holes?: Array<Vec3 | IVec3 | Vec2 | IVec2>[];
}
/**
* @description : 挤压形状生成几何体
* @param {IExtrudeOptionsEx} options
* IExtrudeOptionsEx {
* shape: Array<Vec3 | IVec3 | Vec2 | IVec2>;//shape默认的矩阵为正交矩阵
* path: Array<Vec3 | IVec3>;//挤压路径
* ups?: Array<Vec3 | IVec3>;
* up?: Vec3 | IVec3;
* shapeClosed?: boolean;//闭合为多边形 界面
* pathClosed?: boolean;//首尾闭合为圈
* textureEnable?: boolean;
* smoothAngle?: number;
* sealStart?: boolean;
* sealEnd?: boolean;
* normal?: Vec3,//面的法线
* autoIndex?: boolean,
* index?: { index: number }
* holes?: Array<Vec3 | IVec3 | Vec2 | IVec2>[]
*}
* @return {IGeometry}
* @example :
*
*/
export declare function extrude(options: IExtrudeOptionsEx): IGeometry;
/**
* 挤压
* @param {Polygon|Array<Point|Vec3> } shape 多边形或顶点数组
* @param {Path|Array<Point|Vec3> } path 路径或者或顶点数组
* @param {Object} options {
* isClosed: false,闭合为多边形 界面
* isClosed2: false, 闭合为圈
* textureEnable: true, 计算纹理坐标
* textureScale: new Vec2(1, 1),纹理坐标缩放
* smoothAngle: Math.PI / 180 * 30,大于这个角度则不平滑
* sealStart: true, 是否密封开始面
* sealEnd: true,是否密封结束面}
*/
export declare function extrude_obsolete<T extends Vec3>(shape: ArrayList<T>, arg_path: Array<Vec3> | any, options?: IExtrudeOptions): {
vertices: any[];
index: number[] | undefined;
uvs: any[];
};
export declare enum JoinType {
Square = 0,
Round = 1,
Miter = 2,
Bevel = 0
}
export declare enum EndType {
Square = 0,
Round = 1,
Butt = 2
}
export interface IExtrudeOptionsNext {
shape: Array<Vec3>;
path: Array<Vec3 | IVec3>;
up?: Array<Vec3 | IVec3> | Vec3 | IVec3;
right?: Array<Vec3> | Vec3;
shapeClosed?: boolean;
pathClosed?: boolean;
textureEnable?: boolean;
shapeCenter?: Vec3;
smoothAngle?: number;
enableSmooth?: boolean;
sealStart?: boolean;
sealEnd?: boolean;
normal?: Vec3;
autoIndex?: boolean;
axisPlane?: AxisPlane;
generateUV?: boolean;
index?: {
index: number;
};
holes?: Array<Vec3 | IVec3 | Vec2 | IVec2>[];
jtType?: JoinType;
etType?: EndType;
bevelSize?: any;
}
/**
* 将路径看做挤压操作中心
*
* @param shape
* @param followPath
* @param options
*/
export declare function extrudeNext(options: IExtrudeOptionsNext): IGeometry;