import type { VFXItem } from '../vfx-item'; import { Component } from './component'; import type { ComponentData } from '@galacean/effects-specification'; import type * as spec from '@galacean/effects-specification'; export declare class ConstraintTarget { target: VFXItem | null; weight: number; } export interface ConstraintTargetData { target: spec.DataPath; weight: number; } export interface PositionConstraintData extends ComponentData { positionAtRest: spec.Vector3Data; positionOffset: spec.Vector3Data; weight: number; constrainX: boolean; constrainY: boolean; constrainZ: boolean; targets: ConstraintTargetData[]; } /** * 位置约束组件 * 用于约束物体跟随目标对象的位置 */ export declare class PositionConstraint extends Component { /** * 初始位置(当前元素的初始世界位置) */ private positionAtRest; /** * 位置偏移 */ private positionOffset; /** * 约束权重 (0-1) */ private weight; /** * 是否约束 X 轴 */ private constrainX; /** * 是否约束 Y 轴 */ private constrainY; /** * 是否约束 Z 轴 */ private constrainZ; /** * 约束目标 */ private targets; onStart(): void; onUpdate(dt: number): void; /** * 添加约束目标 * @param target - 目标元素 * @param weight - 权重值 (0-1) */ addTarget(target: VFXItem, weight?: number): void; /** * 移除约束目标 * @param target - 要移除的目标元素 */ removeTarget(target: VFXItem): void; /** * 清除所有约束目标 */ clearTargets(): void; /** * 设置位置偏移 * @param x - X 轴偏移 * @param y - Y 轴偏移 * @param z - Z 轴偏移 */ setPositionOffset(x: number, y: number, z: number): void; /** * 设置全局约束权重 * @param weight - 权重值 (0-1),0 表示保持初始位置,1 表示完全跟随目标 */ setWeight(weight: number): void; /** * 线性插值 * @param start - 起始值 * @param end - 结束值 * @param t - 插值因子 (0-1) */ private lerp; fromData(data: PositionConstraintData): void; }