JSAPI Three API Reference
    正在准备搜索索引...

    类 PathTracker

    路径追踪器,用于沿指定路径进行相机或对象的动画追踪

    PathTracker 支持多种路径数据格式,包括坐标数组、GeoJSON和带帧信息的对象数组。 可以设置不同的视图模式(跟随、锁定、关键帧等)来实现各种追踪效果。

    // 基本用法 - 沿路径追踪相机
    const tracker = engine.add(new mapvthree.PathTracker());

    // 设置路径数据(坐标数组格式)
    tracker.track = [
    [112.368264, 23.176959, 38.553634],
    [112.370264, 23.178959, 40.553634],
    [112.372264, 23.180959, 42.553634]
    ];

    // 开始追踪
    tracker.start({
    duration: 10000,
    pitch: 60,
    range: 100
    });
    // 对象追踪 - 让3D模型沿路径移动
    const model = engine.add(new mapvthree.SimpleModel({
    url: 'path/to/model.glb'
    }));

    const tracker = engine.add(new mapvthree.PathTracker());
    tracker.track = pathCoordinates;
    tracker.object = model; // 设置要追踪的对象
    tracker.start({
    duration: 8000,
    range: 50
    });

    层级

    • TrackerAbstract
      • PathTracker
    索引

    属性

    onFinish: null
    onStart: null
    onUpdate: null

    方法

    • 暂停动画

      返回 null

      当前状态

    • 停止动画

      返回 void

    访问器

    • get currentState(): null

      获取当前状态

      返回 null

    • get interpolateDirectThreshold(): number

      获取插值直接阈值

      返回 number

      当前阈值

    • set interpolateDirectThreshold(value: number): void

      设置插值直接阈值 用于控制路径插值的平滑程度,值越大路径拐角过渡越平滑,但也会越偏离实际路线

      参数

      • value: number

        阈值

      返回 void

    • get isPaused(): boolean

      获取是否暂停

      返回 boolean

    • get isRunning(): boolean

      获取是否正在运行

      返回 boolean

    • get pointHandle(): string

      获取轨迹点插值方式

      返回 string

      当前插值方式

    • set pointHandle(value: string): void

      设置轨迹点插值方式

      参数

      • value: string

        插值方式,可选值:'curve'(曲线插值)

      返回 void

      // 启用曲线插值,使路径更加平滑
      tracker.pointHandle = 'curve';
    • get track(): null | any[]

      获取当前路径数据

      返回 null | any[]

      路径数据

    • set track(target: Object | any[]): void

      设置路径数据

      支持多种数据格式:

      • 坐标数组:[[lng, lat, alt], [lng, lat, alt], ...]
      • GeoJSON:{geometry: {type: 'LineString', coordinates: [...]}, properties: {frameInfo: [...]}}
      • 帧信息数组:[{x, y, z, yaw, pitch, speed, time}, ...]

      参数

      • target: Object | any[]

        路径数据

      返回 void

      // 坐标数组格式
      tracker.track = [
      [112.368264, 23.176959, 38.553634],
      [112.370264, 23.178959, 40.553634]
      ];