【问题标题】:Using tweenlite to tween 3d coordinates使用 tweenlite 补间 3d 坐标
【发布时间】:2011-02-26 22:34:19
【问题描述】:

我正在尝试使用 AS3 将精灵补间到新的 3D 坐标 (x,y,z),我想使用 TweenLite 来做到这一点,但我不知道怎么做?

我不是一个很有经验的程序员,我才开始处理 flash 10 的 3d 可能性,到目前为止,Tweenlite 对我的动画很有帮助。

我一直在尝试像这样使用 QuaternionsPlugin:

TweenLite.to(myMc, 2, {quaternions:{orientation:new Quaternion(x, y, z, w)}});

有 x,y,z 属性,但我不知道 w 代表什么。 我用下面的 Sprite 类尝试了一个示例,但是当我编译它时,它说: 1180: Call to a possible undefined method Quaternion.

package com{
import flash.display.*;
import flash.events.*;  
import com.greensock.TweenLite; 
import com.greensock.plugins.TweenPlugin; 
import com.greensock.plugins.QuaternionsPlugin;  

TweenPlugin.activate([QuaternionsPlugin]); //activation is permanent in the SWF, so this line only needs to be run once.

public class Carousel extends Sprite {
     public function Carousel():void {      

    }

    public function scrollUp():void{
        TweenLite.to(Mc1, 2, {quaternions:{orientation:new Quaternion(246, 244, 0, 400)}});
        TweenLite.to(Mc2, 2, {quaternions:{orientation:new Quaternion(242, 210, 70, 353)}});
    }

    public function scrollDown():void{
        TweenLite.to(Mc1, 2, {quaternions:{orientation:new Quaternion(242, 290, 60, 360)}});
        TweenLite.to(Mc2, 2, {quaternions:{orientation:new Quaternion(246, 244, 0, 400)}});
    }
}

}

非常感谢您的任何提示/帮助!

【问题讨论】:

    标签: actionscript-3 3d coordinates papervision3d gsap


    【解决方案1】:

    Quanternion 对象来自PaperVision3D 的数学课。 “w”代表旋转角度,四元数保证最有效的旋转路径。

    Vector3D 对象有 w 属性。 Matrix3D 的 interpolate() 方法使用四元数,因此您可以使用 Matrix3D 的 intropolate()transformVector() 方法进行补间,或者您可以简单地对显示对象的 x、y 和 z 属性进行补间 - 假设您不需要绝对最高效的渲染。

    【讨论】:

    • 非常感谢,我有更好的理解和更多的东西要挖掘。它很有帮助。
    猜你喜欢
    • 1970-01-01
    • 2012-01-05
    • 2023-03-21
    • 2017-03-29
    • 2022-01-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-02
    相关资源
    最近更新 更多