@three3d/effect
Version:
@three3d/effect 提供了 ThreeJS 的特效
283 lines • 7.21 kB
TypeScript
import { BufferGeometry, CurvePath, type ColorRepresentation, Vector3, Curve } from "three";
import type { PathItem, PathData } from "./tools";
import type { SampleOptions } from "@three3d/tools";
/**
* 保存顶点长度的 AttributeName
*/
export declare const lengthAttributeName = "lineDistance";
/**
* PathGeometry 的 选项
*/
export interface PathGeometryOptions extends SampleOptions {
/**
* 路径的宽度
*/
width?: number;
/**
* 路径起始位置处的长度
*/
startLength?: number;
/**
* 是否自动闭合
*/
autoClose?: boolean;
/**
* 线的颜色
* @remarks
* 顶点颜色
*/
color?: ColorRepresentation | null;
/**
* 线开始处的颜色
* @remarks
* 用于生成路径的从开始颜色到结束颜色的过渡颜色
*
* @defaultValue this.color
*/
startColor?: ColorRepresentation | null;
/**
* 终点处的颜色
* @remarks
* 用于生成路径的从开始颜色到结束颜色的过渡颜色
*
* @defaultValue this.color
*/
endColor?: ColorRepresentation | null;
}
/**
* 用于线性几何体的属性数据
*/
export interface LineAttributesData {
position: number[];
lineDistance: number[];
lengths: number[];
color?: number[];
}
/**
* 用于Mesh几何体的属性数据
*/
export interface MeshAttributesData extends LineAttributesData {
normal?: number[];
uv?: number[];
index?: number[];
points: Vector3[];
}
/**
* 获取曲线的点
* @param curve
* @param options
* @returns
*/
export declare function getCurvePoints(curve: Curve<Vector3>, options?: SampleOptions): Vector3[];
/**
* 根据折线创建用于 PathGeometry 的数据
* @param points
* @param options
* @returns
*/
export declare function createPolylinePathGeometryData(points: Vector3[], options?: PathGeometryOptions | null): {
color: number[];
position: number[];
lineDistance: number[];
lengths: number[];
points: Vector3[];
};
/**
* 路径Geometry
* @remarks
* 可根据曲线、点来生成路径几何体;
* 支持路径追加;
* 支持设置起始长度
* 支持起始-终点颜色渐变
* 支持绘制的指定的长度区间
*
*/
export declare class PathGeometry<Options extends PathGeometryOptions> extends BufferGeometry {
readonly isPathGeometry = true;
constructor(options?: Options);
/**
* 全局选项
* @remarks
* 类级别的选项,对所有后续创建的实例有效;
* 优化级低于实例级别的选项
*
* @defaultValue default_PathGeometryOptions
*/
static options: PathGeometryOptions;
/**
* 全局选项
*/
get globalOptions(): Options;
protected _options: Options | null;
/**
* 实例级别的选项
* @remarks
* 优先级高于 类级别的选项
*/
get options(): Options;
set options(value: Options);
/**
* 路径的宽度
*/
get width(): number;
set width(value: number);
/**
* 采样长度
*/
get sampleLength(): number;
set sampleLength(value: number);
/**
* 采样数
*/
get sampleNum(): number | undefined;
set sampleNum(value: number | undefined);
/**
* 是否自动闭合
*/
get autoClose(): boolean | undefined;
set autoClose(value: boolean | undefined);
/**
* 当前是否已经闭合
*/
get closed(): boolean;
/**
* 线的颜色
* @remarks
* 顶点颜色
*/
get color(): ColorRepresentation | null | undefined;
set color(value: ColorRepresentation | null | undefined);
/**
* 线开始处的颜色
* @remarks
* 用于生成路径的从开始颜色到结束颜色的过渡颜色
*
* @defaultValue this.color
*/
get startColor(): ColorRepresentation | null;
set startColor(value: ColorRepresentation | null);
/**
* 终点处的颜色
* @remarks
* 用于生成路径的从开始颜色到结束颜色的过渡颜色
*
* @defaultValue this.color
*/
get endColor(): ColorRepresentation | null;
set endColor(value: ColorRepresentation | null);
/**
* 路径起始位置处的长度
*/
get startLength(): number;
set startLength(value: number);
/**
* 终点位置处的长度
*/
get endLength(): number;
/**
* 获取顶点对应的长度的数组
*/
get lineDistance(): ArrayLike<number>;
/**
* 获取与指定长度值最近的索引
* @param length - 目标长度值
* @returns
*/
getClosestIndex(length: number): number;
/**
* 获取目标长度值附近的索引
* @param length - 目标长度值
* @param right - 是否获取目标值右侧的索引;
* @returns 当返回 -1 时,表示没找到
*/
getNearbyIndex(length: number, right?: boolean): number;
/**
* 设置绘制的长度范围
* @param startLength
* @param endLength
*/
setDrawLength(startLength: number, endLength?: number | null): void;
protected _startDrawLength: number;
/**
* 开始绘制的长度范围
*/
get startDrawLength(): number;
set startDrawLength(value: number);
protected _endDrawLength: number | null;
/**
* 结束绘制的长度范围
*/
get endDrawLength(): number;
set endDrawLength(value: number);
copy(source: BufferGeometry): this;
/**
* 顶点个数
*/
get vertexCount(): number;
/**
* 路径数据
*/
get pathData(): PathData<Vector3>;
set pathData(value: PathData<Vector3>);
protected _pathData: PathData<Vector3>;
get closedPathData(): PathData<Vector3>;
/**
* 组成路径的曲线列表
*/
get curves(): Curve<Vector3>[];
set curves(value: Curve<Vector3>[]);
protected _curves: Curve<Vector3>[];
/**
* 表示路径的曲线
*/
get curvePath(): CurvePath<Vector3>;
set curvePath(value: CurvePath<Vector3>);
protected _curvePath: CurvePath<Vector3>;
/**
* 闭合的曲线路径
*/
get closedCurvePath(): CurvePath<Vector3>;
/**
* 生成曲线
* @returns
*/
generateCurvePath(): CurvePath<Vector3>;
/**
* 所有的顶点
*/
points: Vector3[];
/**
* 曲线上生成的点
*/
lengths: number[];
/**
* 线性几何体本身的长度
*/
get length(): number;
/**
* curvePath 上的最后一个点
*/
get lastPoint(): Vector3;
/**
* curvePath 上的第一个点
*/
get firstPoint(): Vector3;
append(pathItem: PathItem): void;
set(pathItem: PathItem): void;
updateGeometry(): void;
/**
* 追加新的属性
* @param attrs
*/
appendAttributes(attrs: MeshAttributesData): void;
/**
* 重围所有的 Attributes
* @param attrs
*/
resetAttributes(attrs: MeshAttributesData): void;
/**
* position 属性中的最后一个点
*/
get lastPosition(): Vector3 | null;
}
//# sourceMappingURL=PathGeometry.d.ts.map