Three.js - 动画对象大小 [英] Three.js - Animate object size
问题描述
我一直在遵循本教程: http ://www.html5canvastutorials.com/webgl/html5-canvas-webgl-cylinder-with-three-js/ (或只需复制和粘贴)。它工作非常好(只有我想的FF),但对于我的项目,我需要动画的气缸的大小。
I've been following this tutorial: http://www.html5canvastutorials.com/webgl/html5-canvas-webgl-cylinder-with-three-js/ (or just copy&pasting it). It works very well (FF only I think), but for my "project" I need to animate the size of the Cylinder. How can this be done?
旋转动画效果如下:
three.cylinder.rotation.x += angleChange;
我已经尝试过 size.height
, .height
, scale.height
, scale [0]
等,但我找不到正确的函数。
I've tried several things like size.height
, .height
, scale.height
, scale[0]
and so on, but I can't find the correct function.
有没有人知道如何实现这一点?
Does anyone know how this can be achieved?
推荐答案
animate()
函数,请尝试:
three.cylinder.scale.set( 1, Math.abs( Math.sin( time * 0.0002 ) ), 1 );
这将缩放内部y维度,并保留x和z维度。由于圆柱体的方向,在这种情况下,y维度是长度。
This will scale the internal y-dimension, and leave the x- and z-dimensions unchanged. Due to the orientation of the cylinder, the y-dimension is, in this case, the length.
这篇关于Three.js - 动画对象大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!