【问题标题】:how to tween an objects vertices in three.js如何在three.js中补间对象顶点
【发布时间】:2015-04-04 12:56:59
【问题描述】:

您好,我需要能够补间对象的“高度”。我环顾四周,似乎我需要将 .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;};

【问题讨论】:

  • 为什么不对对象的比例进行补间?

标签: three.js tween.js


【解决方案1】:

这里有更多的东西,将补间设置为变量,不要在补间变量中使用对象声明,声明新的数字变量,然后将补间作为数组运行。 最后,不要像scale = xx那样手动设置对象的参数,总是使用函数scale.set(vals),改变属性还有更多操作要做,比如光照,材质,都必须更新,类函数做更新三.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();

【讨论】:

  • 感谢您的回答!它成功了,虽然我最终不得不做一个翻译而不是规模。
猜你喜欢
  • 2017-04-18
  • 2013-09-28
  • 2017-04-21
  • 2012-05-14
  • 1970-01-01
  • 1970-01-01
  • 2014-10-10
  • 1970-01-01
  • 2019-10-18
相关资源
最近更新 更多