所使用的模型。
當前注視點。
理論值移動速度(m/s)。
out參數,調整旋轉軸及角度偏移。
傳入的物件參數。
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
模型處理函式