没有法线的广告牌朝向相机(点)的方向
所以我有一个平面圆,其构造为:
plane.x = Math.cos(angle) * radius;
plane.z = Math.sin(angle) * radius;
plane.rotationY = (-360 / numItems) * i - 90;
计算平面总数(旋转Y)有多少个角度切片,并将每个平面放置在半径圆上的位置。
然后更新它们绕圆的旋转:
var rotateTo:Number = (-360 / numItems) * currentItem + 90;
TweenLite.to(planesHolder, 1, { rotationY:rotateTo, ease:Quint.easeInOut } );
如您所见,飞机正在盘旋,每个飞机都与圆成 90 度。 我用这个作为参考 - 几乎是这样的: http://papervision2.com /a-simple-papervision-carousel/
现在,我想知道的是,如果可能的话,如何计算每个单独平面的方向度数,使其始终面向没有法线的相机。我尝试过plane.LookAt(camera),但这不起作用。基本上每个平面的方向都应与中间的一个面向相机相同。
不知怎的,我认为我无法修改链接中的示例来做到这一点。
编辑:好的,我写完后回答了我自己的问题。有助于阅读您自己写下的想法。因此,当我单独定向平面并将它们作为一个组旋转时,在上面代码中的组补间之后我所做的就是循环遍历每个平面并将其定向到前平面的 Y 方向,如下所示:
for (var i:int = 0; i < planes.length; i++) {
TweenLite.to(planes[i], 1, { rotationY:(-360 / numItems * rotoItem - 90), ease:Quint.easeInOut } );
}
rotoItem 是前面的那个。案件结案。
So I have a circle of planes which get constructed as:
plane.x = Math.cos(angle) * radius;
plane.z = Math.sin(angle) * radius;
plane.rotationY = (-360 / numItems) * i - 90;
which calculates how many angular slices there are for total number of planes (rotationY) and places each plane into it's place on a circle of radius.
then to update their rotation around the circle I have:
var rotateTo:Number = (-360 / numItems) * currentItem + 90;
TweenLite.to(planesHolder, 1, { rotationY:rotateTo, ease:Quint.easeInOut } );
as you can see planes are circling and each is oriented 90 degrees out from the circle.
I'm using this as a reference - it's pretty much that: http://papervision2.com/a-simple-papervision-carousel/
Now, what I'd like to find out is how could I calculate degree of orientation for each individual plane to always face camera without normal, if it's possible at all. I've tried plane.LookAt(camera), but that doesn't work. Basically every plane should have orientation as the one facing camera in the middle.
Somehow I think I can't modify that example from link to do that.
edit: OK I answered my own question after I wrote it. Helps to read your own thoughts written. So as I'm orienting planes individually and rotating them all as a group, what I did after tween of the group in code above, was to loop through each plane and orient it to the Y orientation of the forward plane as so:
for (var i:int = 0; i < planes.length; i++) {
TweenLite.to(planes[i], 1, { rotationY:(-360 / numItems * rotoItem - 90), ease:Quint.easeInOut } );
}
rotoItem is the one at the front. Case closed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我写完后回答了我自己的问题。有助于阅读您自己写下的想法。因此,当我单独定向平面并将它们作为一个组旋转时,在上面代码中的组补间之后我所做的就是循环遍历每个平面并将其定向到前平面的 Y 方向,如下所示:
rotoItem 是前面的那个。案件结案。
OK I answered my own question after I wrote it. Helps to read your own thoughts written. So as I'm orienting planes individually and rotating them all as a group, what I did after tween of the group in code above, was to loop through each plane and orient it to the Y orientation of the forward plane as so:
rotoItem is the one at the front. Case closed.