如何补间 three.js 中的对象顶点

how to tween an objects vertices in three.js

您好,我需要能够补间对象的 'height'。我环顾四周,似乎我需要将 .z 值等于当前高度的顶点单独补间到它们的新高度。

这是我目前所知道的,但没有任何反应。我在 .z 值等于旧高度的每个顶点上循环调用 tweenVertex。

var tweenVertex = function(object, vertex, height){
    object.geometry.dynamic = true;
    new TWEEN
    .Tween({amount: vertex.z})
    .to({amount: height}, 2000)
    .onUpdate(function () {
         vertex.z = this.amount;
    })
    .start();
    object.geometry.verticesNeedUpdate = true;};

这里还有更多内容,将补间设置为变量,不要在补间变量中使用对象声明,声明新的数字变量,然后 运行 补间作为数组。 最后,不要像scale = xx那样在object中手动设置参数,总是使用函数scale.set(vals),改变属性的操作比较多,比如lighting,materials,都要更新,class 功能为你做任何你在更新后永远不会遇到麻烦 three.js 发布

from = 10;//vertex.z
to = 15;//height

var tween = new TWEEN
    .Tween({amount: from})
    .to({amount:to}, 2000)
    .onUpdate(function () {
         //vertex.z = this.amount;
object.scale.set(0,0,this.amount);
    })
    .start();