Type alias GLTFModelFunction

GLTFModelFunction: ((glTFEntity, position, speed, rotate, object) => void)

Type declaration

    • (glTFEntity, position, speed, rotate, object): void
    • 模型處理函式

      Parameters

      • glTFEntity: CustomGLTFEntity

        所使用的模型。

      • position: Geo3DPoint

        當前注視點。

      • speed: number

        理論值移動速度(m/s)。

      • rotate: {
            offset: number;
            x: number;
            y: number;
            z: number;
        }

        out參數,調整旋轉軸及角度偏移。

        • offset: number
        • x: number
        • y: number
        • z: number
      • object: any

        傳入的物件參數。

      Returns void

      Example

      const glTFModelFunction = (glTFEntity, position, speed, rotate, object) => {
      //設定旋轉軸
      rotate.x = 1;
      rotate.y = 0;
      rotate.z = 0;
      //設定偏移角度
      rotate.offset = 30;
      glTFEntity.update({ position: position });
      glTFEntity.playAll();
      let list = glTFEntity.getAnimationList();
      if (speed < 1.5) {
      let weight = speed / 1.5;
      glTFEntity.setAnimationWeight(0, 1 - weight);
      glTFEntity.setAnimationWeight(1, 0);
      glTFEntity.setAnimationWeight(3, weight);
      if (list.length !== 0) {
      glTFEntity.setPlaySpeed(0, list[0].cycleTime \* (1 + weight));
      glTFEntity.setPlaySpeed(1, list[1].cycleTime \* (1 + weight));
      glTFEntity.setPlaySpeed(3, list[3].cycleTime \* (1 + weight));
      }
      } else {
      let weight = (speed - 1.5) / 1.5;
      if (weight > 1.0) {
      weight = 1.0;
      }
      glTFEntity.setAnimationWeight(0, 0);
      glTFEntity.setAnimationWeight(1, weight);
      glTFEntity.setAnimationWeight(3, 1 - weight);
      if (list.length !== 0) {
      glTFEntity.setPlaySpeed(0, list[0].cycleTime \* (1 + weight));
      glTFEntity.setPlaySpeed(1, list[1].cycleTime \* (1 + weight));
      glTFEntity.setPlaySpeed(3, list[3].cycleTime \* (1 + weight));
      }
      }
      };

Generated using TypeDoc